@ 261105.1

210419.1 · 067c35f01a2dc72ecf3008b48ba903575b8825ce

#182 improved Custom attribute handling

reading declarations

ChangeLog.adoc

@@ -11,10 +11,11 @@  17.04.2021 -  - added `Override` flag to `Custom` style definitions (https://gitlab.com/saalen/highlight/-/issues/182)+  - improved handling of Custom theme attributes (https://gitlab.com/saalen/highlight/-/issues/182)   - fixed wrong color code in edit-kwrite.theme   - added rng file mapping (https://gitlab.com/saalen/highlight/-/merge_requests/129) + == highlight 4.0  23.03.2021

README.adoc

@@ -739,7 +739,7 @@ Colour::    String, defines colour in HTML hex notation (`#rrggbb`) Bold::      Boolean, true if font should be bold (optional) Italic::    Boolean, true if font should be italic (optional) Underline:: Boolean, true if font should be underlined (optional)-Custom::    Array, contains `Format`, `Style` and `Override` for custom styles+Custom::    Array, contains `Format` and `Style` for custom styles  ==== Theme elements @@ -843,7 +843,7 @@ SemanticTokenTypes = {  --ErrorMessage = { --  Custom = {---    { Format = "html", Style = "color: blue; border:solid 1px blue; margin-left: 3em", Override = true }+--    { Format = "html", Style = "color: blue; border:solid 1px blue; margin-left: 3em" } --  } --} --------------------------------------------------------------------------------

README_DE.adoc

@@ -746,7 +746,7 @@ Colour::    String, Farbe in Hex-Notation (`#rrggbb`) Bold::      Boolean, True wenn Font bold sein soll (optional) Italic::    Boolean, True wenn Font kursiv sein soll (optional) Underline:: Boolean, True wenn Font unterstrichen sein soll (optional)-Custom::    Array, enthaelt `Format`, `Style` und `Override` Attribute fuer spezielle Formatierungen+Custom::    Array, enthaelt `Format` und `Style`` Attribute fuer spezielle Formatierungen  ==== Theme-Elemente @@ -859,7 +859,7 @@ SemanticTokenTypes = {  --ErrorMessage = { --  Custom = {---    { Format = "html", Style = "color: blue; border:solid 1px blue; margin-left: 3em", Override = true }+--    { Format = "html", Style = "color: blue; border:solid 1px blue; margin-left: 3em" } --  } --} --------------------------------------------------------------------------------

src/core/themereader.cpp

@@ -66,6 +66,8 @@ OutputType ThemeReader::getOutputType(const string &typeDesc) { void ThemeReader::initStyle(ElementStyle& style, const Diluculum::LuaVariable& var) { +    style.setCustomStyle(""); // Init with a default value.+     if (var["Custom"].value()!=Diluculum::Nil) {          int idx=1;@@ -75,12 +77,8 @@ void ThemeReader::initStyle(ElementStyle& style, const Diluculum::LuaVariable& v             if (getOutputType(var["Custom"][idx]["Format"].value().asString()) == outputType) {                  style.setCustomStyle (var["Custom"][idx]["Style"].value().asString() );--                if (var["Custom"][idx]["Override"].value()!=Diluculum::Nil) {-                    style.setCustomOverride (var["Custom"][idx]["Override"].value().asBoolean() );-                }--                return;+                style.setCustomOverride ( true );+                break;             }             idx++;         }@@ -89,22 +87,30 @@ void ThemeReader::initStyle(ElementStyle& style, const Diluculum::LuaVariable& v     string styleColor="#000000";     bool styleBold=false, styleItalic=false, styleUnderline=false; -    if (var["Colour"].value()!=Diluculum::Nil)+    if (var["Colour"].value()!=Diluculum::Nil) {         styleColor= var["Colour"].value().asString();-    if (var["Bold"].value()!=Diluculum::Nil)+        style.setCustomOverride(false);+    }++    if (var["Bold"].value()!=Diluculum::Nil) {         styleBold= var["Bold"].value().asBoolean();-    if (var["Italic"].value()!=Diluculum::Nil)+        style.setCustomOverride(false);+    }++    if (var["Italic"].value()!=Diluculum::Nil) {         styleItalic= var["Italic"].value().asBoolean();-    if (var["Underline"].value()!=Diluculum::Nil)+        style.setCustomOverride(false);+    }++    if (var["Underline"].value()!=Diluculum::Nil) {         styleUnderline= var["Underline"].value().asBoolean();+        style.setCustomOverride(false);+    }      style.setColour(Colour(styleColor));     style.setBold(styleBold);     style.setItalic(styleItalic);     style.setUnderline(styleUnderline);--    if (var["Underline"].value()!=Diluculum::Nil)-        styleUnderline= var["Underline"].value().asBoolean(); }  bool ThemeReader::load ( const string &styleDefinitionPath , OutputType type, bool loadSemanticStyles)@@ -180,7 +186,10 @@ bool ThemeReader::load ( const string &styleDefinitionPath , OutputType type, bo             hover.setCustomOverride(true);             hover.setCustomStyle ("cursor:help");             errorMessages.setCustomStyle ("border:solid 1px red; margin-left: 3em");-            line.setCustomStyle("user-select: none");++            if (line.getCustomStyle().empty()) {+                line.setCustomStyle("user-select: none");+            }         }          if (outputType==LATEX) {@@ -202,7 +211,6 @@ bool ThemeReader::load ( const string &styleDefinitionPath , OutputType type, bo             initStyle(errors, ls["Error"]);         } -         keywordStyles.clear();         semanticStyleMap.clear(); 

themes/greenlcd.theme

@@ -16,6 +16,9 @@ Operator       = { Colour="#2fe7a9" } LineComment = BlockComment Interpolation  = Escape +Error = { Colour = "#f200cc" }+ErrorMessage = { Colour="#2fe7a9", Custom = { { Format = "html", Style = "color:#f200cc; border:solid 1px #f200cc; margin-left: 3em" } } }+ Keywords = {   { Colour= "#00ed00", Bold=true },   { Colour= "#00ed00" },@@ -25,11 +28,6 @@ Keywords = {   { Colour= "#c6ff73" }, } --Error = { Colour = "#f200cc" }--ErrorMessage = { Custom = { { Format = "html", Style = "color: #f200cc; border:solid 1px #f200cc; margin-left: 3em", Override = true } } }- -- new LSP based elements:  SemanticTokenTypes  = {