# HG changeset patch # User Edouard Tisserant # Date 1660212695 -7200 # Node ID c5070b6973ba5354aced3496b394fc15c02c1510 # Parent d74eb1be6abe3ca54e9aeea8ffbc5d786f353ce5 SVGHMI: add support for multiline widget declaration using svg:desc. Declaration started in inkscape:label and interupted by a '\' can be continued in the description field. After an empty line, the rest of the description field is left for description text. diff -r d74eb1be6abe -r c5070b6973ba svghmi/hmi_tree.ysl2 --- a/svghmi/hmi_tree.ysl2 Tue Aug 02 11:53:37 2022 +0200 +++ b/svghmi/hmi_tree.ysl2 Thu Aug 11 12:11:35 2022 +0200 @@ -121,6 +121,7 @@ > «$indent» «local-name()» foreach "@*" > «local-name()»="«.»" > \n + if "text()" > «text()»\n apply "*", mode="testtree" { with "indent" value "concat($indent,'>')" }; diff -r d74eb1be6abe -r c5070b6973ba svghmi/parse_labels.ysl2 --- a/svghmi/parse_labels.ysl2 Tue Aug 02 11:53:37 2022 +0200 +++ b/svghmi/parse_labels.ysl2 Thu Aug 11 12:11:35 2022 +0200 @@ -15,9 +15,29 @@ // const "pathregex",!"'^([^\[,]+)(\[[^\]]+\])?([-.\d,]*)$'"!; +const "newline" | +const "twonewlines", "concat($newline,$newline)"; + template "*", mode="parselabel" { - const "label","@inkscape:label"; + const "part","@inkscape:label"; + const "desc", "svg:desc"; + + // add svg:desc field if continuation "\" marker is found at the end of label + const "len","string-length($part)"; + const "has_continuation", "substring($part,$len,1)='\\'"; + const "label" choose{ + when "$has_continuation" { + const "_continuation", "substring-before($desc, $twonewlines)"; + const "continuation" choose { + when "$_continuation" value "$_continuation"; + otherwise value "$desc"; + } + value "concat(substring($part,1,$len - 1),translate($continuation,$newline,''))"; + } + otherwise value "$part"; + } + const "id","@id"; const "description", "substring-after($label,'HMI:')"; @@ -100,7 +120,15 @@ } } } - if "svg:desc" desc value "svg:desc/text()"; + choose{ + when "$has_continuation" { + const "_continuation", "substring-after($desc, $twonewlines)"; + if "$_continuation" + desc value "$_continuation"; + } + otherwise + if "$desc" desc value "$desc/text()"; + } } } diff -r d74eb1be6abe -r c5070b6973ba tests/projects/svghmi_scrollbar/svghmi_0@svghmi/svghmi.svg --- a/tests/projects/svghmi_scrollbar/svghmi_0@svghmi/svghmi.svg Tue Aug 02 11:53:37 2022 +0200 +++ b/tests/projects/svghmi_scrollbar/svghmi_0@svghmi/svghmi.svg Thu Aug 11 12:11:35 2022 +0200 @@ -60,12 +60,12 @@ showgrid="false" units="px" inkscape:zoom="0.64" - inkscape:cx="-438.80601" - inkscape:cy="183.59799" - inkscape:window-width="3200" - inkscape:window-height="1672" + inkscape:cx="476.03774" + inkscape:cy="444.53549" + inkscape:window-width="1600" + inkscape:window-height="836" inkscape:window-x="0" - inkscape:window-y="54" + inkscape:window-y="27" inkscape:window-maximized="1" showguides="true" inkscape:guide-bbox="true" @@ -745,8 +745,14 @@ + @.range +@.position +@.size + +my tailor is rich + deedewesfsdf +cedwee