Fix highlighter colors management.
[GB.HIGHLIGHT] * NEW: TextHighlighter: Syntax for specifying a default to use if the color name is not defined in the theme. * NEW: TextHighlighter: 'Key' is now the internal highlighter name. * NEW: TextHighlighter: 'Name' now returns the highlighter display name. * NEW: TextHighlighter: 'Register()' now takes the highlighter internal name, its display name, and the path of the definition file. * BUG: TextHighlighter: 'List' property is now more accurate. * NEW: TextHighlighter: 'Colors' is a new property that returns the color names used by a specific highlighter. * BUG: TextHighlighterStyle: Fix the 'Background' property. * NEW: TextHighlighterTheme: Make color names translatable. * NEW: TextHighlighterTheme: Some colors are now registered as "common colors". They are returned by the 'Colors' property. * NEW: TextHighlighterTheme: '_Register()' has been renamed as '_RegisterColor()'. * NEW: Many highlighter fixes. Define default colors.
This commit is contained in:
parent
f3419c8786
commit
b2e4cea881
22 changed files with 501 additions and 163 deletions
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 9.1 KiB |
179
comp/src/gb.highlight/.lang/fr.po
Normal file
179
comp/src/gb.highlight/.lang/fr.po
Normal file
|
@ -0,0 +1,179 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gb.highlight 3.18.90\n"
|
||||
"POT-Creation-Date: 2023-11-01 00:01 UTC\n"
|
||||
"PO-Revision-Date: 2023-10-31 23:33 UTC\n"
|
||||
"Last-Translator: benoit <benoit@benoit-TOWER>\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Added"
|
||||
msgstr "Ajout"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "AtRule"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Background"
|
||||
msgstr "Arrière-plan"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Breakpoint"
|
||||
msgstr "Point d'arrêt"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Class"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Color"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Comment"
|
||||
msgstr "Commentaire"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Constant"
|
||||
msgstr "Constante"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Current"
|
||||
msgstr "Ligne courante"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Datatype"
|
||||
msgstr "Type de données"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Documentation"
|
||||
msgstr "Documentation"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Error"
|
||||
msgstr "Erreur"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Escape"
|
||||
msgstr "Échappement"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Function"
|
||||
msgstr "Fonction"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Highlight"
|
||||
msgstr "Mise en évidence"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Id"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Identifier"
|
||||
msgstr "Identificateur"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Important"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Keyword"
|
||||
msgstr "Mot-clef"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Label"
|
||||
msgstr "Étiquette"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Normal"
|
||||
msgstr "Normal"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Number"
|
||||
msgstr "Nombre"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Operator"
|
||||
msgstr "Opérateur"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Preprocessor"
|
||||
msgstr "Préprocesseur"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "PseudoClass"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Removed"
|
||||
msgstr "Suppression"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Selection"
|
||||
msgstr "Sélection"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "String"
|
||||
msgstr "Chaîne de caractères"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Symbol"
|
||||
msgstr "Symbole"
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Tag"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "TagAttribute"
|
||||
msgstr ""
|
||||
|
||||
#: Names.module:37
|
||||
msgid "Unit"
|
||||
msgstr ""
|
||||
|
||||
#: TextHighlighter.class:50
|
||||
msgid "C"
|
||||
msgstr "C"
|
||||
|
||||
#: TextHighlighter.class:52
|
||||
msgid "C++"
|
||||
msgstr "C++"
|
||||
|
||||
#: TextHighlighter.class:54
|
||||
msgid "Cascading Style Sheet"
|
||||
msgstr "Feuille de style"
|
||||
|
||||
#: TextHighlighter.class:56
|
||||
msgid "Diff"
|
||||
msgstr "Différences"
|
||||
|
||||
#: TextHighlighter.class:58
|
||||
msgid "HTML"
|
||||
msgstr "HTML"
|
||||
|
||||
#: TextHighlighter.class:60
|
||||
msgid "Javascript"
|
||||
msgstr "Javascript"
|
||||
|
||||
#: TextHighlighter.class:62
|
||||
msgid "Shell"
|
||||
msgstr "Shell"
|
||||
|
||||
#: TextHighlighter.class:64
|
||||
msgid "SQL"
|
||||
msgstr "SQL"
|
||||
|
||||
#: TextHighlighter.class:66
|
||||
msgid "Gambas Web Page"
|
||||
msgstr "Page web Gambas"
|
||||
|
||||
#: TextHighlighter.class:73
|
||||
msgid "Gambas"
|
||||
msgstr "Gambas"
|
|
@ -7,6 +7,7 @@ Component=gb.image
|
|||
Component=gb.eval
|
||||
Component=gb.pcre
|
||||
TabSize=2
|
||||
Language=fr
|
||||
Translate=1
|
||||
Language=en_US
|
||||
Type=Component
|
||||
Packager=1
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
Static Public Path As String
|
||||
Static Public Keywords As New String[]
|
||||
|
||||
Static Private $sHighlighter As String
|
||||
|
||||
Static Private $iIndent As Integer
|
||||
Static Private $sLastCode As String
|
||||
|
||||
|
@ -28,8 +30,9 @@ Private $iCurrentCommand As Integer
|
|||
Private $iCurrentChild As Integer
|
||||
Private $sContinue As String
|
||||
|
||||
Static Public Sub Init(sPath As String)
|
||||
Static Public Sub Init(sHighlighter As String, sPath As String)
|
||||
|
||||
$sHighlighter = sHighlighter
|
||||
Path = sPath
|
||||
$cSubst.Clear
|
||||
$cState.Clear
|
||||
|
@ -54,7 +57,6 @@ Static Public Sub Subst(sValue As String) As String
|
|||
|
||||
End
|
||||
|
||||
|
||||
Static Public Sub Define(sVar As String, sValue As String)
|
||||
|
||||
$cSubst[sVar] = Me.Subst(sValue)
|
||||
|
@ -74,14 +76,18 @@ Public Sub _new(Optional sLine As String)
|
|||
If iPos = 0 Then Error.Raise("Syntax error")
|
||||
sColor = Mid$(sLine, iPos + 1, -1)
|
||||
sLine = Left(sLine, iPos - 1)
|
||||
Else
|
||||
sColor = String.UCaseFirst(sLine)
|
||||
iPos = InStr(sColor, "=")
|
||||
If iPos Then
|
||||
sColor = Trim(Left$(sColor, iPos - 1))
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If Not sColor Then sColor = String.UCaseFirst(sLine)
|
||||
|
||||
If sLine Not Match "[A-Za-z][A-Za-z0-9.]*" Then Error.Raise("Incorrect character in state name")
|
||||
Name = Replace(sLine, ".", "_")
|
||||
|
||||
ColorIndex = TextHighlighterTheme._Register(sColor)
|
||||
ColorIndex = TextHighlighterTheme._RegisterColor(sColor)
|
||||
|
||||
' If sTitle Then
|
||||
' sCurrent = $cTitle[Name]
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
' Gambas module file
|
||||
|
|
@ -22,10 +22,11 @@ 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["c"]
|
||||
With TextHighlighter["gambas"]
|
||||
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/main/share/gambas.h"))
|
||||
Print .ToANSI(File.Load("~/gambas/git/master/comp/src/gb.desktop/.src/Desktop.class"))
|
||||
End With
|
||||
|
||||
End
|
||||
|
|
49
comp/src/gb.highlight/.src/Names.module
Normal file
49
comp/src/gb.highlight/.src/Names.module
Normal file
|
@ -0,0 +1,49 @@
|
|||
' Gambas module file
|
||||
|
||||
Public ColorNames As String[] =
|
||||
[
|
||||
("Added"),
|
||||
("AtRule"),
|
||||
("Attribute"),
|
||||
("Background"),
|
||||
("Breakpoint"),
|
||||
("Class"),
|
||||
("Comment"),
|
||||
("Color"),
|
||||
("Command"),
|
||||
("Constant"),
|
||||
("Current"),
|
||||
("Datatype"),
|
||||
("Diff"),
|
||||
("Documentation"),
|
||||
("Entity"),
|
||||
("Error"),
|
||||
("Escape"),
|
||||
("Expansion"),
|
||||
("File"),
|
||||
("Function"),
|
||||
("Keyword"),
|
||||
("Highlight"),
|
||||
("Id"),
|
||||
("Index"),
|
||||
("Important"),
|
||||
("Identifier"),
|
||||
("Label"),
|
||||
("Markup"),
|
||||
("Normal"),
|
||||
("Number"),
|
||||
("Operator"),
|
||||
("Position"),
|
||||
("Preprocessor"),
|
||||
("PseudoClass"),
|
||||
("RegExp"),
|
||||
("Removed"),
|
||||
("Selection"),
|
||||
("SheBang"),
|
||||
("String"),
|
||||
("Symbol"),
|
||||
("Tag"),
|
||||
("TagAttribute"),
|
||||
("Unit"),
|
||||
("Value")
|
||||
]
|
|
@ -9,7 +9,8 @@ Class Color
|
|||
|
||||
Static Property Read List As String[]
|
||||
|
||||
Static Private $cRegister As New Collection
|
||||
Static Private $cPath As New Collection
|
||||
Static Private $cNames As New Collection
|
||||
|
||||
Public CanRewrite As Boolean
|
||||
Public TextAfter As String
|
||||
|
@ -17,8 +18,10 @@ Public LengthAdded As Integer
|
|||
Public Limit As Boolean
|
||||
Public Comment As Boolean
|
||||
|
||||
Property Read Key As String
|
||||
Property Read Name As String
|
||||
Property Read Keywords As String[]
|
||||
Property Read Colors As String[]
|
||||
|
||||
Private $iPos As Integer
|
||||
Private $iLevel As Integer
|
||||
|
@ -37,11 +40,38 @@ Private $hTheme As TextHighlighterTheme
|
|||
Static Public Sub _init()
|
||||
|
||||
Dim sFile As String
|
||||
Dim sKey As String
|
||||
Dim sName As String
|
||||
|
||||
For Each sFile In Dir("highlight", "*.highlight")
|
||||
Register("./highlight" &/ sFile)
|
||||
sKey = File.BaseName(sFile)
|
||||
Select Case sKey
|
||||
Case "c"
|
||||
sName = ("C")
|
||||
Case "cplusplus"
|
||||
sName = ("C++")
|
||||
Case "css"
|
||||
sName = ("Cascading Style Sheet")
|
||||
Case "diff"
|
||||
sName = ("Diff")
|
||||
Case "html"
|
||||
sName = ("HTML")
|
||||
Case "javascript"
|
||||
sName = ("Javascript")
|
||||
Case "sh"
|
||||
sName = ("Shell")
|
||||
Case "sql"
|
||||
sName = ("SQL")
|
||||
Case "webpage"
|
||||
sName = ("Gambas Web Page")
|
||||
Case Else
|
||||
sName = String.UCaseFirst(sKey)
|
||||
End Select
|
||||
Register(sKey, sName)
|
||||
Next
|
||||
|
||||
$cNames["gambas"] = ("Gambas")
|
||||
|
||||
End
|
||||
|
||||
Static Private Sub Load(Name As String) As Class
|
||||
|
@ -51,7 +81,7 @@ Static Private Sub Load(Name As String) As Class
|
|||
Name = LCase(Name)
|
||||
Try Return Classes["_TextHighlighter_" & Name]
|
||||
|
||||
sPath = $cRegister[Name]
|
||||
sPath = $cPath[Name]
|
||||
If Not sPath Then Error.Raise("Unknown highlighter: " & Name)
|
||||
|
||||
CreateCustomHighlighter(Name, sPath)
|
||||
|
@ -63,37 +93,91 @@ Catch
|
|||
|
||||
End
|
||||
|
||||
Static Public Sub _get(Name As String) As TextHighlighter
|
||||
Static Public Sub _get(Key As String) As TextHighlighter
|
||||
|
||||
Return Load(Name).AutoCreate()
|
||||
Return Load(Key).AutoCreate()
|
||||
|
||||
End
|
||||
|
||||
Static Public Sub _Create(Name As String) As TextHighlighter
|
||||
Static Public Sub _Create(Key As String) As TextHighlighter
|
||||
|
||||
Load(Name)
|
||||
Return Object.New("_TextHighlighter_" & Name)
|
||||
Load(Key)
|
||||
Return Object.New("_TextHighlighter_" & Key)
|
||||
|
||||
End
|
||||
|
||||
Static Public Sub Register(Path As String, Optional Name As String)
|
||||
Static Public Sub Register(Key As String, Name As String, Optional Path As String)
|
||||
|
||||
Dim sComp As String
|
||||
Dim sLine As String
|
||||
Dim iPos As Integer
|
||||
Dim sColor As String
|
||||
Dim sDefault As String
|
||||
Dim aLines As String[]
|
||||
Dim iLine As Integer
|
||||
Dim aInclude As String[]
|
||||
|
||||
If Not Name Then Name = LCase(File.BaseName(Path))
|
||||
If Not IsAscii(Name) Then Error.Raise("Highligher name must be ASCII")
|
||||
If Key Not Match "[a-z_]*" Then Error.Raise("Incorrect highlighter identifier")
|
||||
|
||||
If File.IsRelative(Path) Then
|
||||
If Path Not Begins "./" Then
|
||||
sComp = Component.FindFromPath(".." &/ Path)
|
||||
If Not sComp Then
|
||||
Path = ".../" &/ Path
|
||||
Else
|
||||
Path = "./" & sComp &/ Path
|
||||
Endif
|
||||
If Not Path Then
|
||||
Path = "highlight" &/ Key & ".highlight"
|
||||
Else If File.IsRelative(Path) Then
|
||||
sComp = Component.FindFromPath(".." &/ Path)
|
||||
If Not sComp Then
|
||||
Path = ".../" &/ Path
|
||||
Else
|
||||
Path = "./" & sComp &/ Path
|
||||
Endif
|
||||
Endif
|
||||
$cRegister[Name] = Path
|
||||
|
||||
$cPath[Key] = Path
|
||||
$cNames[Key] = Name
|
||||
|
||||
aLines = Split(File.Load(Path), "\n")
|
||||
While iLine < aLines.Count
|
||||
|
||||
sLine = Trim(aLines[iLine])
|
||||
Inc iLine
|
||||
|
||||
If sLine Begins "@include " Then
|
||||
sLine = Trim(Mid$(sLine, 9))
|
||||
If Not sLine Then Continue
|
||||
aInclude = Split(File.Load(File.Dir(Path) &/ sLine), "\n")
|
||||
aLines.Insert(aInclude, iLine)
|
||||
Continue
|
||||
Endif
|
||||
|
||||
If Not IsLetter(Left(sLine)) Then Continue
|
||||
If sLine Not Ends ":" Then Continue
|
||||
|
||||
sLine = Left(sLine, -1)
|
||||
sColor = ""
|
||||
sDefault = ""
|
||||
|
||||
If sLine Ends "}" Then
|
||||
iPos = InStr(sLine, "{")
|
||||
If iPos = 0 Then Continue
|
||||
sColor = Mid$(sLine, iPos + 1, -1)
|
||||
sLine = Left(sLine, iPos - 1)
|
||||
iPos = InStr(sColor, "=")
|
||||
If iPos Then
|
||||
sDefault = Trim(Mid$(sColor, iPos + 1))
|
||||
sColor = Trim(Left$(sColor, iPos - 1))
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If Not sColor Then sColor = String.UCaseFirst(sLine)
|
||||
If sLine Not Match "[A-Za-z][A-Za-z0-9.]*" Then Continue
|
||||
|
||||
TextHighlighterTheme._RegisterColor(sColor, Key, sDefault)
|
||||
|
||||
Wend
|
||||
|
||||
End
|
||||
|
||||
Public Sub RegisterColor(Name As String) As Integer
|
||||
|
||||
Return TextHighlighterTheme._RegisterColor(Name, Me.Key)
|
||||
|
||||
End
|
||||
|
||||
|
@ -166,7 +250,7 @@ Static Private Sub CreateCustomHighlighter(sHighlight As String, sPath As String
|
|||
Try Mkdir sDir
|
||||
Try Mkdir sDir &/ ".src"
|
||||
|
||||
CState.Init(sPath)
|
||||
CState.Init(sHighlight, sPath)
|
||||
|
||||
hDefault = New CState
|
||||
|
||||
|
@ -342,13 +426,13 @@ End
|
|||
|
||||
Private Sub HighlightLine(sLine As String)
|
||||
|
||||
Dim bCanRewrite As Boolean
|
||||
'Dim bCanRewrite As Boolean
|
||||
|
||||
bCanRewrite = Me.CanRewrite
|
||||
Me.CanRewrite = False
|
||||
'bCanRewrite = Me.CanRewrite
|
||||
'Me.CanRewrite = False
|
||||
$aHighlight = Me.Run(sLine & "\n", $aState)
|
||||
$sLine = sLine
|
||||
Me.CanRewrite = bCanRewrite
|
||||
'Me.CanRewrite = bCanRewrite
|
||||
$aStyles = $hTheme._GetStyles()
|
||||
$iPos = 1
|
||||
$iIndex = 0
|
||||
|
@ -400,25 +484,19 @@ Private Function Keywords_Read() As String[]
|
|||
|
||||
End
|
||||
|
||||
Private Function Name_Read() As String
|
||||
|
||||
Dim sClass As String
|
||||
Dim iPos As Integer
|
||||
|
||||
sClass = Object.Type(Me)
|
||||
iPos = RInStr(sClass, "_")
|
||||
Try Return LCase(Mid$(sClass, iPos + 1))
|
||||
|
||||
End
|
||||
|
||||
Static Private Function List_Read() As String[]
|
||||
|
||||
Dim aList As String[]
|
||||
Dim sKey As String
|
||||
Dim sFile As String
|
||||
|
||||
aList = New String[]
|
||||
For Each $cRegister
|
||||
sKey = $cRegister.Key
|
||||
For Each sFile In Dir(".gambas", "_TEXTHIGHLIGHTER_*")
|
||||
aList.Add(LCase(Mid$(sFile, InStr(sFile, "_", 2) + 1)))
|
||||
Next
|
||||
|
||||
For Each $cPath
|
||||
sKey = $cPath.Key
|
||||
If sKey Begins "_" Then Continue
|
||||
aList.Add(sKey)
|
||||
Next
|
||||
|
@ -634,3 +712,36 @@ Public Sub ToANSI(Text As String, Optional Theme As TextHighlighterTheme) As Str
|
|||
|
||||
End
|
||||
|
||||
|
||||
Private Function Colors_Read() As String[]
|
||||
|
||||
Return TextHighlighterTheme._GetHighlighterColors(Me.Key)
|
||||
|
||||
End
|
||||
|
||||
Private Function Key_Read() As String
|
||||
|
||||
Dim sClass As String
|
||||
Dim iPos As Integer
|
||||
|
||||
sClass = Object.Type(Me)
|
||||
iPos = InStr(sClass, "_", 2)
|
||||
Try Return LCase(Mid$(sClass, iPos + 1))
|
||||
|
||||
End
|
||||
|
||||
Private Function Name_Read() As String
|
||||
|
||||
Return GetName(Key_Read())
|
||||
|
||||
End
|
||||
|
||||
Static Public Sub GetName(Key As String) As String
|
||||
|
||||
Dim sName As String
|
||||
|
||||
sName = $cNames[Key]
|
||||
If Not sName Then sName = Key
|
||||
Return sName
|
||||
|
||||
End
|
||||
|
|
|
@ -163,12 +163,12 @@ End
|
|||
|
||||
Private Function Background_Read() As Boolean
|
||||
|
||||
Return ["Background", "Selection", "CurrentLine", "Current", "Breakpoint", "Highlight", "Alternate"].Exist($sKey)
|
||||
Return ["Background", "Selection", "Current", "Breakpoint", "Highlight"].Exist($sKey)
|
||||
|
||||
End
|
||||
|
||||
Private Function Name_Read() As String
|
||||
|
||||
Return $sKey
|
||||
Return Tr$($sKey)
|
||||
|
||||
End
|
||||
|
|
|
@ -8,12 +8,24 @@ Static Property Read Colors As String[]
|
|||
|
||||
Static Private $bStylesModified As Boolean
|
||||
Static Private $cColorIndex As New Collection
|
||||
Static Private $cColorsByHighlighter As New Collection
|
||||
|
||||
Property Settings As String
|
||||
|
||||
Private $cStyles As New Collection
|
||||
|
||||
Static Private $cCopy As Collection = ["Class": "Datatype", "Id": "Keyword", "Element": "Function", "Property": "Symbol", "Pseudo": "Keyword", "Rule": "Preprocessor", "Important": "Number", "File": "Comment", "Header": "Documentation", "Position": "Keyword", "Markup": "Keyword", "Attribute": "Function", "Value": "String", "Entity": "Datatype", "WebMarkup": "Preprocessor", "WebComment": "Documentation", "WebArgument": "Preprocessor"]
|
||||
Static Private $cDefault As New Collection '= ["Class": "Datatype", "Identifier": "Symbol", "Element": "Function", "Property": "Symbol", "Pseudo": "Keyword", "Rule": "Preprocessor", "Important": "Number", "File": "Comment", "Header": "Documentation", "Position": "Keyword", "Markup": "Keyword", "Attribute": "Function", "Value": "String", "Entity": "Datatype", "WebMarkup": "Preprocessor", "WebComment": "Documentation", "WebArgument": "Preprocessor"]
|
||||
|
||||
Static Public Sub _init()
|
||||
|
||||
Dim sColor As String
|
||||
|
||||
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
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
|
@ -100,8 +112,8 @@ Public Sub _Load(Path As String)
|
|||
Dim sName As String
|
||||
Dim hStyle As TextHighlighterStyle
|
||||
Dim cStyleSet As New Collection
|
||||
Dim sCopy As String
|
||||
Dim bOldTheme As Boolean
|
||||
Dim sDefault As String
|
||||
|
||||
aTheme = Split(File.Load(Path), "\n")
|
||||
If aTheme[0] <> "[Gambas Highlighting Theme 1.0]" Then
|
||||
|
@ -128,8 +140,8 @@ Public Sub _Load(Path As String)
|
|||
|
||||
Next
|
||||
|
||||
For Each sCopy In $cCopy
|
||||
If Not cStyleSet.Exist($cCopy.Key) Then Me[$cCopy.Key] = Me[sCopy]
|
||||
For Each sDefault In $cDefault
|
||||
If Not cStyleSet.Exist($cDefault.Key) Then Me[$cDefault.Key] = Me[sDefault]
|
||||
Next
|
||||
|
||||
Return
|
||||
|
@ -212,22 +224,51 @@ Public Sub Invert()
|
|||
|
||||
End
|
||||
|
||||
Static Public Sub _Register(sColor As String) As Integer
|
||||
Static Public Sub _RegisterColor(Name As String, Optional Highlighter As String, sDefault As String) As Integer
|
||||
|
||||
Dim iIndex As Integer
|
||||
Dim aColors As String[]
|
||||
|
||||
If sColor = "*" Or If sColor = "Normal" Then Return 0
|
||||
|
||||
Try iIndex = $cColorIndex[sColor]
|
||||
If iIndex = 0 Then
|
||||
iIndex = $cColorIndex.Count + 1
|
||||
$cColorIndex[sColor] = iIndex
|
||||
$bStylesModified = True
|
||||
If Name = "*" Or If Name = "Normal" Then
|
||||
iIndex = 0
|
||||
Else
|
||||
Try iIndex = $cColorIndex[Name]
|
||||
If iIndex = 0 And If Highlighter Then
|
||||
iIndex = $cColorIndex.Count + 1
|
||||
$cColorIndex[Name] = iIndex
|
||||
$bStylesModified = True
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If Highlighter Then
|
||||
aColors = $cColorsByHighlighter[Highlighter]
|
||||
If Not aColors Then
|
||||
aColors = New String[]
|
||||
$cColorsByHighlighter[Highlighter] = aColors
|
||||
Endif
|
||||
|
||||
If Not aColors.Exist(Name) Then
|
||||
aColors.Add(Name)
|
||||
aColors.Sort()
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If sDefault Then $cDefault[Name] = sDefault
|
||||
|
||||
Return iIndex
|
||||
|
||||
End
|
||||
|
||||
Static Public Sub _GetHighlighterColors(sHighlighter As String) As String[]
|
||||
|
||||
Dim aColors As String[]
|
||||
|
||||
aColors = $cColorsByHighlighter[sHighlighter]
|
||||
If Not aColors Then aColors = New String[]
|
||||
Return aColors.Copy().Sort()
|
||||
|
||||
End
|
||||
|
||||
Public Sub _GetStyles() As TextHighlighterStyle[]
|
||||
|
||||
Static aStyles As TextHighlighterStyle[]
|
||||
|
@ -254,12 +295,6 @@ End
|
|||
|
||||
Static Private Function Colors_Read() As String[]
|
||||
|
||||
Dim aColor As New String[]
|
||||
|
||||
For Each $cColorIndex
|
||||
aColor.Add($cColorIndex.Key)
|
||||
Next
|
||||
|
||||
Return aColor
|
||||
Return _GetHighlighterColors("*")
|
||||
|
||||
End
|
||||
|
|
|
@ -21,8 +21,8 @@ Static Public Sub _init()
|
|||
Component.Load("gb.eval")
|
||||
|
||||
' Follow the order of Highlight class constants
|
||||
For Each sColor In ["", "Normal", "Selection", "", "Highlight", "", "Added", "Removed", "Error", "Comment", "Documentation", "Keyword", "Function", "Operator", "Symbol", "Number", "String", "", "Current", "Datatype", "Preprocessor", "Escape", "Label", "Constant"]
|
||||
If sColor Then $cState[I] = TextHighlighterTheme._Register(sColor)
|
||||
For Each sColor In ["", "Normal", "", "", "", "", "", "", "Error", "Comment", "Documentation", "Keyword", "Function", "Operator", "Symbol", "Number", "String", "", "", "Datatype", "Preprocessor", "Escape", "Label", "Constant"]
|
||||
If sColor Then $cState[I] = Me.RegisterColor(sColor)
|
||||
Inc I
|
||||
Next
|
||||
|
||||
|
|
|
@ -1,44 +1,2 @@
|
|||
documentation:
|
||||
from /** to */
|
||||
comment:
|
||||
from /* to */
|
||||
from //
|
||||
@include webpage.include
|
||||
string:
|
||||
from " to "
|
||||
from ' to '
|
||||
escape:
|
||||
match /\\[fnrtv0'"\\]/
|
||||
match /\\c[A-Za-z]/
|
||||
match /\\x[0-9a-fA-F]{2}/
|
||||
match /\\u[0-9a-fA-F]{4}/
|
||||
match /\\u{[0-9a-fA-F]+}/
|
||||
@include webpage.include
|
||||
string.subst{String}:
|
||||
from ` to `
|
||||
escape:
|
||||
match /\\[fnrtv0'"\\]/
|
||||
match /\\c[A-Za-z]/
|
||||
match /\\x[0-9a-fA-F]{2}/
|
||||
match /\\u[0-9a-fA-F]{4}/
|
||||
match /\\u{[0-9a-fA-F]+}/
|
||||
subst{Escape}:
|
||||
from ${ to } with webpage_javascript
|
||||
@include webpage.include
|
||||
regexp{Datatype}:
|
||||
match //.*/[a-z]*/
|
||||
regexp.escape{Escape}:
|
||||
match /\\./
|
||||
number:
|
||||
match /[+-]?[0-9]*(\.[0-9]+)?([Ee][+-]?[0-9]+)?/
|
||||
match /0x[0-9a-fA-F]*/
|
||||
keyword:
|
||||
keyword @javascript.keyword
|
||||
function:
|
||||
keyword function
|
||||
constant:
|
||||
keyword false null this true undefined NaN Infinity
|
||||
operator:
|
||||
symbol { } . >= + << ! = >>= ; == - >> ~ += >>>= ( , != * >>> && -= &= ) < === % & || *= |= [ > !== ++ | ? %= ^= -- ^ : <<= ] <= / /=
|
||||
identifier:
|
||||
match /[A-Za-z_$][A-Za-z_$0-9]*/
|
||||
@include javascript.highlight
|
||||
|
|
|
@ -27,5 +27,5 @@ datatype:
|
|||
keyword void signed unsigned char short int long float double int64_t uint64_t int32_t uint32_t int16_t uint16_t int8_t uint8_t uchar ushort uint ulong intptr_t uintptr_t wchar_t
|
||||
operator:
|
||||
symbol { } . >= + << ! = >>= ; == - >> ~ += ( , != * && -= &= ) < % & || *= |= [ > ++ | ? %= ^= -- ^ : <<= ] <= / /=
|
||||
identifier:
|
||||
symbol:
|
||||
match /[A-Za-z_$][A-Za-z_$0-9]*/
|
|
@ -33,5 +33,5 @@ operator:
|
|||
symbol { } . ; ( , ) [ :: ] -> ? : <=> ->* .* *
|
||||
operator.action{Function}:
|
||||
symbol = >= + << ! >>= == - >> ~ += != && -= &= < % & || *= |= > ++ | %= ^= -- ^ <<= <= / /=
|
||||
identifier:
|
||||
symbol:
|
||||
match /[A-Za-z_$][A-Za-z_$0-9]*/
|
|
@ -8,18 +8,18 @@ block{Operator}:
|
|||
match /$(IDENT)/
|
||||
property{Operator}:
|
||||
from : to ;
|
||||
color{Constant}:
|
||||
color{Color=Constant}:
|
||||
match /#[0-9A-Fa-f]{6}/
|
||||
match /#[0-9A-Fa-f]{3}/
|
||||
number:
|
||||
match /$(NUMBER)/
|
||||
unit{Function}:
|
||||
unit{Unit=Function}:
|
||||
match /$(IDENT)/
|
||||
important:
|
||||
match "%"
|
||||
important{Important=Constant}:
|
||||
match "!important"
|
||||
identifier{Normal}:
|
||||
match /$(IDENT)/
|
||||
symbol %
|
||||
string:
|
||||
from " to "
|
||||
from ' to '
|
||||
|
|
|
@ -16,19 +16,19 @@ documentation:
|
|||
from /** to */
|
||||
comment:
|
||||
from /* to */
|
||||
atrule{Preprocessor}:
|
||||
atrule{AtRule=Preprocessor}:
|
||||
match /@$(IDENT)/
|
||||
class{Datatype}:
|
||||
class{Class=Datatype}:
|
||||
match /\.$(IDENT)/
|
||||
pseudoclass{Pseudo}:
|
||||
pseudoclass{PseudoClass=Keyword}:
|
||||
match /::?$(IDENT)/
|
||||
id{Function}:
|
||||
id{Id=Function}:
|
||||
match /#$(IDENT)/
|
||||
attribute{Keyword}:
|
||||
tag{Tag=Keyword}:
|
||||
match /$(IDENT)/
|
||||
type{Keyword}:
|
||||
type{TagAttribute=Keyword}:
|
||||
from [ to ]
|
||||
string{Normal}:
|
||||
string{TagAttribute}:
|
||||
from ' to '
|
||||
operator:
|
||||
symbol > , +
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
diff{Function}:
|
||||
diff{Diff=Function}:
|
||||
limit
|
||||
from /^diff/
|
||||
index{Keyword}:
|
||||
index{Index=Keyword}:
|
||||
from /^index/
|
||||
file{Keyword}:
|
||||
file{File=Keyword}:
|
||||
match /^(\+\+\+|---)/
|
||||
file.path{String}:
|
||||
match /.*?\n/
|
||||
position{Datatype}:
|
||||
position{Position=Datatype}:
|
||||
from /^@@/ to @@
|
||||
added{Added}:
|
||||
from /^\+/ to "\n"
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
$(IDENT)=[a-zA-Z0-9-]+
|
||||
doctype{Preprocessor}:
|
||||
doctype{Doctype=Preprocessor}:
|
||||
from <!DOCTYPE to >
|
||||
comment:
|
||||
from <!-- to -->
|
||||
entity{Function}:
|
||||
entity{Entity=Function}:
|
||||
match /&[A-Za-z]+;/
|
||||
match /&#[0-9]+;/
|
||||
javascript{Keyword}:
|
||||
javascript{Markup}:
|
||||
from /<script.*?(type=["']text/javascript['"])?.*?>/ to </script> with javascript
|
||||
css{Keyword}:
|
||||
css{Markup}:
|
||||
from /<style.*?(type=["']text/css['"])?.*?>/ to </style> with css
|
||||
markup{Keyword}:
|
||||
markup{Markup=Keyword}:
|
||||
from /<$(IDENT)/ to //?>/
|
||||
attribute{Datatype}:
|
||||
attribute{Attribute=Datatype}:
|
||||
match /$(IDENT)/
|
||||
equal{Normal}:
|
||||
symbol =
|
||||
value{String}:
|
||||
value{Value=String}:
|
||||
from " to "
|
||||
from ' to '
|
||||
string.entity{Escape}:
|
||||
string.entity{Entity}:
|
||||
match /&[A-Za-z]+;/
|
||||
match /&#[0-9]+;/
|
||||
value.unquoted{String}:
|
||||
value.unquoted{Value}:
|
||||
match /[^"'`=<>\s]+/
|
||||
markup.close{Keyword}:
|
||||
markup.close{Markup}:
|
||||
match /</$(IDENT)\s*>/
|
||||
|
|
|
@ -22,7 +22,7 @@ string.subst{String}:
|
|||
match /\\u{[0-9a-fA-F]+}/
|
||||
subst{Escape}:
|
||||
from ${ to } with javascript
|
||||
regexp{Datatype}:
|
||||
regexp{RegExp=Datatype}:
|
||||
match //.*?/[a-z]*/
|
||||
regexp.escape{Escape}:
|
||||
match /\\./
|
||||
|
@ -38,5 +38,5 @@ constant:
|
|||
keyword false null this true undefined NaN Infinity
|
||||
operator:
|
||||
symbol { } . >= + << ! = >>= ; == - >> ~ += >>>= ( , != * >>> && -= &= ) < === % & || *= |= [ > !== ++ | ? %= ^= -- ^ : <<= ] <= / /=
|
||||
identifier:
|
||||
symbol:
|
||||
match /[A-Za-z_$][A-Za-z_$0-9]*/
|
|
@ -1,6 +1,6 @@
|
|||
escape{Normal}:
|
||||
match /\\./
|
||||
shebang{Preprocessor}:
|
||||
shebang{SheBang=Preprocessor}:
|
||||
from /^#!/
|
||||
comment:
|
||||
from /^#/
|
||||
|
@ -16,11 +16,11 @@ string.double{String}:
|
|||
from " to "
|
||||
escape:
|
||||
match /\\[$`'"\\]/
|
||||
expansion{Datatype}:
|
||||
expansion{Expansion=Datatype}:
|
||||
match /\$[A-Za-z0-9_]+/
|
||||
expansion.brace{Datatype}:
|
||||
expansion.brace{Expansion}:
|
||||
from ${ to } with sh
|
||||
command{Datatype}:
|
||||
command{Expansion}:
|
||||
from ` to ` with sh
|
||||
string.ansi{String}:
|
||||
from $' to '
|
||||
|
@ -31,18 +31,18 @@ string.ansi{String}:
|
|||
match /\\u[0-9a-fA-F]{4}/
|
||||
match /\\u[0-9a-fA-F]{8}/
|
||||
match /\\c[a-zA-Z]/
|
||||
expansion{Datatype}:
|
||||
expansion{Expansion}:
|
||||
match /\$[A-Za-z0-9_]+/
|
||||
expansion.brace{Datatype}:
|
||||
expansion.brace{Expansion}:
|
||||
from ${ to } with sh
|
||||
command{Datatype}:
|
||||
command{Expansion}:
|
||||
from ` to ` with sh
|
||||
keyword:
|
||||
keyword function do else test for to in fi if elif then return exit while until done break continue select case esac
|
||||
operator:
|
||||
symbol -gt -lt -ge -ne -le -eq
|
||||
symbol { } $ # [ ] <<< . + << = >> == - ~ += ( , != * -= &= ;; ) < % & ]; @ ! ; > | ? ^ : <= /
|
||||
function:
|
||||
function{Command=Function}:
|
||||
keyword echo read cd which rm cp mv rmdir cat grep awk tr sed sleep clear sudo su source eval export time date pwd set unset chown chmod exec alias unalias bg bind builtin caller command compgen complete compopt declare dirs disown enable fc fg getopts hash help history jobs kill let local logout mapfile popd printf pushd readarray readonly shift shopt suspend test times trap type typeset ulimit umask wait
|
||||
identifier:
|
||||
symbol:
|
||||
match /[A-Za-z_][A-Za-z_0-9]*/
|
||||
|
|
|
@ -34,5 +34,5 @@ keyword:
|
|||
keyword @sql.keyword
|
||||
function:
|
||||
keyword @sql.function
|
||||
identifier:
|
||||
symbol:
|
||||
match /[A-Za-z_$][A-Za-z_$0-9]*/
|
|
@ -1,31 +1,31 @@
|
|||
$(IDENT)=[a-zA-Z0-9-]+
|
||||
doctype{Preprocessor}:
|
||||
doctype{Doctype=Preprocessor}:
|
||||
from <!DOCTYPE to >
|
||||
comment:
|
||||
from <!-- to -->
|
||||
@include webpage.include
|
||||
entity{Function}:
|
||||
entity{Entity=Function}:
|
||||
match /&[A-Za-z]+;/
|
||||
match /&#[0-9]+;/
|
||||
javascript{Keyword}:
|
||||
javascript{Markup}:
|
||||
from /<script.*?(type=["']text/javascript['"])?.*?>/ to </script> with _webpage_javascript
|
||||
css{Keyword}:
|
||||
css{Markup}:
|
||||
from /<style.*?(type=["']text/css['"])?.*?>/ to </style> with _webpage_css
|
||||
markup{Keyword}:
|
||||
markup{Markup=Keyword}:
|
||||
from /<$(IDENT)/ to //?>/
|
||||
@include webpage.include
|
||||
attribute{Datatype}:
|
||||
attribute{Attribute=Datatype}:
|
||||
match /$(IDENT)/
|
||||
equal{Normal}:
|
||||
symbol =
|
||||
value{String}:
|
||||
value{Value=String}:
|
||||
from " to "
|
||||
from ' to '
|
||||
string.entity{Escape}:
|
||||
string.entity{Entity}:
|
||||
match /&[A-Za-z]+;/
|
||||
match /&#[0-9]+;/
|
||||
@include webpage.include
|
||||
value.unquoted{String}:
|
||||
value.unquoted{Value}:
|
||||
match /[^"'`=<>\s]+/
|
||||
markup.close{Keyword}:
|
||||
markup.close{Markup}:
|
||||
match /</$(IDENT)\s*>/
|
||||
|
|
Loading…
Reference in a new issue