From 879d0796fc7b5afd8e4f634a1b8c18631fc88bba Mon Sep 17 00:00:00 2001 From: gambas Date: Sat, 6 Nov 2021 12:03:05 +0100 Subject: [PATCH] TextHighlighterTheme: Fix ToString() method. [GB.EVAL.HIGHLIGHT] * BUG: TextHighlighterTheme: Fix ToString() method. * NEW: TextHighlighterTheme: Initialize directly from the IDE 'gambas' theme file. --- .../.src/TextHighlighterTheme.class | 78 +++++-------------- 1 file changed, 21 insertions(+), 57 deletions(-) diff --git a/comp/src/gb.eval.highlight/.src/TextHighlighterTheme.class b/comp/src/gb.eval.highlight/.src/TextHighlighterTheme.class index 764b50cdd..7c1457b9b 100644 --- a/comp/src/gb.eval.highlight/.src/TextHighlighterTheme.class +++ b/comp/src/gb.eval.highlight/.src/TextHighlighterTheme.class @@ -13,52 +13,7 @@ Private $cStyles As New Collection Public Sub _new() - Add("Background", &HFFFFFF) - Add("Normal", &H000000) - Add("Keyword", &H000000, True) - Add("Datatype", &HDF6B00, True) - Add("Function", &H3398C3, True) - Add("Operator", &H000000, True) - Add("Symbol", &H000000) - Add("Number", &HE00000, True) - Add("String", &H7F0000) - Add("Comment", &H808080) - Add("Documentation", &H808080, True) - Add("Preprocessor", &H008040, True) - Add("Breakpoint", &HFF5F5F) - Add("Current", &H42C9FF) - Add("Selection", &HC3EDFF) - Add("Highlight", &H6FE06F) - Add("CurrentLine", &HE7F3FF) - Add("Error", &HBF0303, False, True) - Add("Escape", &H7F0000, True, False, True) - Add("Label", &H000000, False, False, True) - Add("Constant", &H800080, True) - Add("Alternate", &HFFFF7F) - Add("Added", &H006000, True) - Add("Removed", &H800000).Strikeout = True - - Me["Class"] = Me["Datatype"] - Me["Id"] = Me["Function"] - Me["Element"] = Me["Keyword"] - Me["Property"] = Me["Symbol"] - Add("Pseudo", &H404040, True) - Me["Rule"] = Me["Preprocessor"] - Me["Important"] = Me["Number"] - Me["Important"].Underline = True - - Me["File"] = Me["Documentation"] - Me["Header"] = Me["Comment"] - Me["Position"] = Me["Keyword"] - - Me["Markup"] = Me["Function"] - Me["Attribute"] = Me["Operator"] - Me["Value"] = Me["String"] - Me["Entity"] = Me["Datatype"] - - Me["WebMarkup"] = Me["Preprocessor"] - Me["WebComment"] = Me["Documentation"] - Add("WebArgument", &H008040) + _Load("gambas") End @@ -132,9 +87,8 @@ Public Sub Save(Path As String) End -Static Public Sub Load(Path As String) As TextHighlighterTheme +Public Sub _Load(Path As String) - Dim hTheme As TextHighlighterTheme Dim aTheme As String[] Dim I As Integer Dim sLine As String @@ -142,12 +96,6 @@ Static Public Sub Load(Path As String) As TextHighlighterTheme Dim sName As String Dim hStyle As TextHighlighterStyle - hTheme = New TextHighlighterTheme - - If File.IsRelative(Path) Then - Path = ".." &/ Path - Endif - aTheme = Split(File.Load(Path), "\n") If aTheme[0] <> "[Gambas Highlighting Theme 1.0]" And If aTheme[0] <> "[Theme]" Then Goto RAISE_ERROR @@ -160,11 +108,11 @@ Static Public Sub Load(Path As String) As TextHighlighterTheme If Not sName Or If Not IsAlnum(sName) Then Goto RAISE_ERROR hStyle = TextHighlighterStyle.FromString(UnQuote(Trim(Mid$(sLine, iPos + 1)))) - hTheme[sName] = hStyle + Me[sName] = hStyle Next - Return hTheme + Return RAISE_ERROR: @@ -172,6 +120,22 @@ RAISE_ERROR: End + +Static Public Sub Load(Path As String) As TextHighlighterTheme + + Dim hTheme As TextHighlighterTheme + + hTheme = New TextHighlighterTheme + + If File.IsRelative(Path) Then + Path = ".." &/ Path + Endif + + hTheme._Load(Path) + Return hTheme + +End + Public Sub ToString() As String Dim hStyle As TextHighlighterStyle @@ -179,7 +143,7 @@ Public Sub ToString() As String aStyle = New String[] For Each hStyle In $cStyles - aStyle.Add(hStyle.Name & "=" & hStyle.ToString()) + aStyle.Add(hStyle.Key & "=" & hStyle.ToString()) Next Return aStyle.Join(";")