From d3b4e7af35cb224a07dd3c1fe40c6bd64fcf052c Mon Sep 17 00:00:00 2001 From: PlantUML Date: Thu, 12 Dec 2024 16:34:03 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20prepare=20jaws=20deployment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/net/atmp/ImageBuilder.java | 14 ++-- .../command/note/CommandFactoryNote.java | 2 +- .../note/CommandFactoryNoteActivity.java | 2 +- .../note/CommandFactoryNoteOnEntity.java | 2 +- .../note/CommandFactoryNoteOnLink.java | 2 +- .../note/CommandFactoryTipOnEntity.java | 2 +- .../FactorySequenceNoteAcrossCommand.java | 2 +- .../sequence/FactorySequenceNoteCommand.java | 2 +- .../FactorySequenceNoteOnArrowCommand.java | 2 +- ...FactorySequenceNoteOverSeveralCommand.java | 2 +- src/net/sourceforge/plantuml/jaws/Jaws.java | 14 ++-- .../plantuml/jaws/JawsWarning.java | 46 +++++++++++++ .../plantuml/klimt/creole/Display.java | 22 ++++++- .../plantuml/nwdiag/NwDiagram.java | 3 +- .../plantuml/nwdiag/core/NServer.java | 6 +- src/net/sourceforge/plantuml/skin/Pragma.java | 17 +++-- .../sourceforge/plantuml/tim/TContext.java | 7 +- .../plantuml/tim/builtin/LeftAlign.java | 64 +++++++++++++++++++ .../plantuml/tim/builtin/RightAlign.java | 64 +++++++++++++++++++ 19 files changed, 243 insertions(+), 32 deletions(-) create mode 100644 src/net/sourceforge/plantuml/jaws/JawsWarning.java create mode 100644 src/net/sourceforge/plantuml/tim/builtin/LeftAlign.java create mode 100644 src/net/sourceforge/plantuml/tim/builtin/RightAlign.java diff --git a/src/net/atmp/ImageBuilder.java b/src/net/atmp/ImageBuilder.java index 1947b705046..01596de027a 100644 --- a/src/net/atmp/ImageBuilder.java +++ b/src/net/atmp/ImageBuilder.java @@ -43,6 +43,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; +import java.util.EnumSet; import java.util.List; import java.util.Random; import java.util.Set; @@ -61,6 +62,7 @@ import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.braille.UGraphicBraille; import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.jaws.JawsWarning; import net.sourceforge.plantuml.klimt.UStroke; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.ColorMapper; @@ -123,7 +125,7 @@ public class ImageBuilder { private TitledDiagram titledDiagram; private boolean randomPixel; private String warningOrError; - private boolean warningNewline; + private Set warnings = EnumSet.noneOf(JawsWarning.class); public static ImageBuilder imageBuilder(FileFormatOption fileFormatOption) { return new ImageBuilder(fileFormatOption); @@ -223,7 +225,7 @@ public ImageBuilder styled(TitledDiagram diagram) { seed = diagram.seed(); titledDiagram = diagram; warningOrError = diagram.getWarningOrError(); - warningNewline = diagram.getPragma().printBackslashNewlineWarning(); + warnings = diagram.getPragma().warnings(); return this; } @@ -250,7 +252,7 @@ public byte[] writeByteArray() throws IOException { private ImageData writeImageInternal(OutputStream os) throws IOException { XDimension2D dim = getFinalDimension(); XDimension2D dimWarning = null; - if (warningNewline) { + if (warnings.size() > 0) { dimWarning = getWarningDimension(fileFormatOption.getFileFormat().getDefaultStringBounder()); dim = dim.atLeast(dimWarning.getWidth(), 0); dim = dim.delta(15, dimWarning.getHeight() + 20); @@ -264,7 +266,7 @@ private ImageData writeImageInternal(OutputStream os) throws IOException { UGraphic ug = createUGraphic(dim, scaleFactor, titledDiagram == null ? Pragma.createEmpty() : titledDiagram.getPragma()); - if (warningNewline) { + if (warnings.size() > 0) { drawWarning(dimWarning, ug.apply(UTranslate.dy(5)), dim.getWidth()); ug = ug.apply(UTranslate.dy(dimWarning.getHeight() + 20)); } @@ -298,8 +300,8 @@ private void drawWarning(XDimension2D dimWarning, UGraphic ug, double fullWidth) final HColorSet set = HColorSet.instance(); - final HColor back = set.getColorOrWhite("ffffcc"); - final HColor border = set.getColorOrWhite("ffdd88"); + final HColor back = set.getColorOrWhite("ffffcc"); + final HColor border = set.getColorOrWhite("ffdd88"); ug = ug.apply(back.bg()).apply(border); final URectangle rect = URectangle.build(fullWidth - 10, dimWarning.getHeight() + 10).rounded(5); ug.apply(new UTranslate(5, 0)).apply(UStroke.withThickness(3)).draw(rect); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java index 736fddfebd3..e386aa36963 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNote.java @@ -126,7 +126,7 @@ protected CommandExecutionResult executeNow(final AbstractEntityDiagram diagram, ParserPass currentPass) throws NoSuchColorException { // StringUtils.trim(lines, false); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); - lines = lines.subExtract(1, 1); + lines = lines.subExtract(1, 1).expandsJaws5(); lines = lines.removeEmptyColumns(); final Display display = lines.toDisplay(); return executeInternal(diagram, line0, display); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java index b11bb6a00ec..41570025f57 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteActivity.java @@ -105,7 +105,7 @@ public final CommandExecutionResult executeNow(final ActivityDiagram diagram, Bl throws NoSuchColorException { // StringUtils.trim(lines, true); final RegexResult arg = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); - lines = lines.subExtract(1, 1); + lines = lines.subExtract(1, 1).expandsJaws5(); lines = lines.removeEmptyColumns(); Display strings = lines.toDisplay(); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java index 1dbb9202bf5..a5906a03e9b 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java @@ -198,7 +198,7 @@ protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, ParserPass currentPass) throws NoSuchColorException { // StringUtils.trim(lines, false); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); - lines = lines.subExtract(1, 1); + lines = lines.subExtract(1, 1).expandsJaws5(); lines = lines.removeEmptyColumns(); final Display display = lines.toDisplay(); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java index 378211e8ce3..f87c45cd6c8 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java @@ -117,7 +117,7 @@ public String getPatternEnd() { protected CommandExecutionResult executeNow(final CucaDiagram system, BlocLines lines, ParserPass currentPass) throws NoSuchColorException { final String line0 = lines.getFirst().getTrimmed().getString(); - lines = lines.subExtract(1, 1); + lines = lines.subExtract(1, 1).expandsJaws5(); lines = lines.removeEmptyColumns(); if (lines.size() > 0) { final RegexResult arg = getStartingPattern().matcher(line0); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java index c53ddc5af07..4966b87d5ff 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java @@ -141,7 +141,7 @@ protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, ParserPass currentPass) throws NoSuchColorException { // StringUtils.trim(lines, false); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); - lines = lines.subExtract(1, 1); + lines = lines.subExtract(1, 1).expandsJaws5(); lines = lines.removeEmptyColumns(); final Display display = lines.toDisplay(); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java index a6947e12ef9..b4f2d06afcd 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java @@ -130,7 +130,7 @@ protected CommandExecutionResult executeNow(final SequenceDiagram diagram, BlocL ParserPass currentPass) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); - lines = lines.removeEmptyColumns(); + lines = lines.removeEmptyColumns().expandsJaws5(); final Display display = lines.toDisplay(); return executeInternal(diagram, line0, diagram.manageVariable(display)); } diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java index 7b0c154999b..0dfed3f1f03 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java @@ -125,7 +125,7 @@ protected CommandExecutionResult executeNow(final SequenceDiagram diagram, BlocL ParserPass currentPass) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); - lines = lines.removeEmptyColumns(); + lines = lines.removeEmptyColumns().expandsJaws5(); final Display display = lines.toDisplay(); return executeInternal(diagram, line0, diagram.manageVariable(display)); } diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java index d93baf35464..0796dcd4584 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java @@ -125,7 +125,7 @@ public String getPatternEnd() { protected CommandExecutionResult executeNow(final SequenceDiagram diagram, BlocLines lines, ParserPass currentPass) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); - lines = lines.subExtract(1, 1); + lines = lines.subExtract(1, 1).expandsJaws5(); lines = lines.removeEmptyColumns(); final Display display = lines.toDisplay(); return executeInternal(diagram, line0, diagram.manageVariable(display)); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java index 6f4427372fb..12e0a024956 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java @@ -144,7 +144,7 @@ public String getPatternEnd() { protected CommandExecutionResult executeNow(final SequenceDiagram diagram, BlocLines lines, ParserPass currentPass) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); - lines = lines.subExtract(1, 1); + lines = lines.subExtract(1, 1).expandsJaws5(); lines = lines.removeEmptyColumns(); final Display display = lines.toDisplay(); return executeInternal(diagram, line0, diagram.manageVariable(display)); diff --git a/src/net/sourceforge/plantuml/jaws/Jaws.java b/src/net/sourceforge/plantuml/jaws/Jaws.java index 940c7f2db74..470da706639 100644 --- a/src/net/sourceforge/plantuml/jaws/Jaws.java +++ b/src/net/sourceforge/plantuml/jaws/Jaws.java @@ -44,11 +44,17 @@ public class Jaws { public static final char BLOCK_E1_NEWLINE = '\uE100'; - public static final char BLOCK_E1_REAL_BACKSLASH = '\uE101'; - public static final char BLOCK_E1_START_TEXTBLOCK = '\uE102'; - public static final char BLOCK_E1_END_TEXTBLOCK = '\uE103'; - public static final char BLOCK_E1_REAL_TABULATION = '\uE104'; + public static final char BLOCK_E1_NEWLINE_LEFT_ALIGN = '\uE101'; + public static final char BLOCK_E1_NEWLINE_RIGHT_ALIGN = '\uE102'; + + public static final char BLOCK_E1_REAL_BACKSLASH = '\uE110'; + public static final char BLOCK_E1_REAL_TABULATION = '\uE111'; + public static final char BLOCK_E1_INVISIBLE_QUOTE = '\uE121'; + public static final char BLOCK_E1_START_TEXTBLOCK = '\uE122'; + public static final char BLOCK_E1_END_TEXTBLOCK = '\uE123'; + + private final List output = new ArrayList(); public Jaws(List input) { diff --git a/src/net/sourceforge/plantuml/jaws/JawsWarning.java b/src/net/sourceforge/plantuml/jaws/JawsWarning.java new file mode 100644 index 00000000000..bbff87bda49 --- /dev/null +++ b/src/net/sourceforge/plantuml/jaws/JawsWarning.java @@ -0,0 +1,46 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.jaws; + +public enum JawsWarning { + BACKSLASH_NEWLINE, + BACKSLASH_LEFT, + BACKSLASH_RIGHT, + BACKSLASH_TABULATION, + BACKSLASH_BACKSLASH, + OTHER + +} diff --git a/src/net/sourceforge/plantuml/klimt/creole/Display.java b/src/net/sourceforge/plantuml/klimt/creole/Display.java index 67cab59fa57..f9123c6461d 100644 --- a/src/net/sourceforge/plantuml/klimt/creole/Display.java +++ b/src/net/sourceforge/plantuml/klimt/creole/Display.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.abel.Entity; import net.sourceforge.plantuml.jaws.Jaws; import net.sourceforge.plantuml.jaws.JawsStrange; +import net.sourceforge.plantuml.jaws.JawsWarning; import net.sourceforge.plantuml.klimt.LineBreakStrategy; import net.sourceforge.plantuml.klimt.UStroke; import net.sourceforge.plantuml.klimt.color.HColor; @@ -270,27 +271,42 @@ else if (sub.startsWith("") || sub.startsWith("") || sub.startsWi final char c2 = s.charAt(i + 1); i++; if (c2 == 'n' || c2 == 'r' || c2 == 'l') { - if (c2 == 'r') + if (c2 == 'r') { naturalHorizontalAlignment = HorizontalAlignment.RIGHT; - else if (c2 == 'l') + pragma.addWarning(JawsWarning.BACKSLASH_RIGHT); + } else if (c2 == 'l') { naturalHorizontalAlignment = HorizontalAlignment.LEFT; + pragma.addWarning(JawsWarning.BACKSLASH_LEFT); + } else { + pragma.addWarning(JawsWarning.BACKSLASH_NEWLINE); + } result.add(current.toString()); current.setLength(0); } else if (c2 == 't') { current.append('\t'); + pragma.addWarning(JawsWarning.BACKSLASH_TABULATION); } else if (c2 == '\\') { current.append(c2); + pragma.addWarning(JawsWarning.BACKSLASH_BACKSLASH); } else { current.append(c); current.append(c2); } - pragma.addBackslashNewlineWarning(); + pragma.addWarning(JawsWarning.OTHER); } else if (c == Jaws.BLOCK_E1_REAL_TABULATION) { // current.append('\t'); current.append(c); } else if (c == Jaws.BLOCK_E1_REAL_BACKSLASH) { current.append('\\'); + } else if (c == Jaws.BLOCK_E1_NEWLINE_LEFT_ALIGN) { + naturalHorizontalAlignment = HorizontalAlignment.LEFT; + result.add(current.toString()); + current.setLength(0); + } else if (c == Jaws.BLOCK_E1_NEWLINE_RIGHT_ALIGN) { + naturalHorizontalAlignment = HorizontalAlignment.RIGHT; + result.add(current.toString()); + current.setLength(0); } else if (rawMode == false && c == Jaws.BLOCK_E1_NEWLINE) { result.add(current.toString()); current.setLength(0); diff --git a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java index 84a3e87f95e..eb0fc06a37f 100644 --- a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java +++ b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; +import net.sourceforge.plantuml.jaws.Jaws; import net.sourceforge.plantuml.klimt.UTranslate; import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.creole.Display; @@ -354,7 +355,7 @@ private StyleSignatureBasic getStyleDefinitionNetwork(SName sname) { private TextBlock toTextBlockForNetworkName(String name, String s) { if (s != null) - name += "\\n" + s; + name += "" + Jaws.BLOCK_E1_NEWLINE + s; final StyleBuilder styleBuilder = getSkinParam().getCurrentStyleBuilder(); final Style style = getStyleDefinitionNetwork(SName.network).getMergedStyle(styleBuilder); diff --git a/src/net/sourceforge/plantuml/nwdiag/core/NServer.java b/src/net/sourceforge/plantuml/nwdiag/core/NServer.java index 9b86dfae509..4123a50bf6b 100644 --- a/src/net/sourceforge/plantuml/nwdiag/core/NServer.java +++ b/src/net/sourceforge/plantuml/nwdiag/core/NServer.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.decoration.symbol.USymbol; import net.sourceforge.plantuml.decoration.symbol.USymbols; +import net.sourceforge.plantuml.jaws.Jaws; import net.sourceforge.plantuml.jaws.JawsStrange; import net.sourceforge.plantuml.klimt.Fashion; import net.sourceforge.plantuml.klimt.color.HColor; @@ -144,8 +145,9 @@ public TextBlock toTextBlock(SName sname, String s) { if (s.length() == 0) return TextBlockUtils.empty(0, 0); - s = s.replace(", ", "\\n"); - return Display.getWithNewlines(skinParam.getPragma(), s).create(getFontConfiguration(sname), HorizontalAlignment.LEFT, skinParam); + s = s.replace(", ", "" + Jaws.BLOCK_E1_NEWLINE); + return Display.getWithNewlines(skinParam.getPragma(), s).create(getFontConfiguration(sname), + HorizontalAlignment.LEFT, skinParam); } private StyleSignatureBasic getStyleDefinition(SName sname) { diff --git a/src/net/sourceforge/plantuml/skin/Pragma.java b/src/net/sourceforge/plantuml/skin/Pragma.java index 5c62253fede..89abbc24573 100644 --- a/src/net/sourceforge/plantuml/skin/Pragma.java +++ b/src/net/sourceforge/plantuml/skin/Pragma.java @@ -35,13 +35,17 @@ */ package net.sourceforge.plantuml.skin; +import java.util.EnumSet; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.jaws.JawsWarning; public class Pragma { private final Map values = new LinkedHashMap(); - private boolean backslashNewlineWarning; + private final Set warnings = EnumSet.noneOf(JawsWarning.class); private Pragma() { } @@ -106,12 +110,13 @@ public boolean legacyReplaceBackslashNByNewline() { return true; } - public void addBackslashNewlineWarning() { - this.backslashNewlineWarning = true; + public void addWarning(JawsWarning warning) { + this.warnings.add(warning); } - public boolean printBackslashNewlineWarning() { - return backslashNewlineWarning && isTrue(getValue("warning")); + public Set warnings() { + if (isTrue(getValue("warning"))) + return this.warnings; + return null; } - } diff --git a/src/net/sourceforge/plantuml/tim/TContext.java b/src/net/sourceforge/plantuml/tim/TContext.java index 2f2fe4efabd..92d8768f901 100644 --- a/src/net/sourceforge/plantuml/tim/TContext.java +++ b/src/net/sourceforge/plantuml/tim/TContext.java @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.DefinitionsContainer; import net.sourceforge.plantuml.FileSystem; import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.jaws.Jaws; import net.sourceforge.plantuml.json.Json; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; @@ -110,6 +111,7 @@ import net.sourceforge.plantuml.tim.builtin.JsonMerge; import net.sourceforge.plantuml.tim.builtin.JsonRemove; import net.sourceforge.plantuml.tim.builtin.JsonSet; +import net.sourceforge.plantuml.tim.builtin.LeftAlign; import net.sourceforge.plantuml.tim.builtin.Lighten; import net.sourceforge.plantuml.tim.builtin.LoadJson; import net.sourceforge.plantuml.tim.builtin.LogicalAnd; @@ -129,6 +131,7 @@ import net.sourceforge.plantuml.tim.builtin.RetrieveProcedure; import net.sourceforge.plantuml.tim.builtin.ReverseColor; import net.sourceforge.plantuml.tim.builtin.ReverseHsluvColor; +import net.sourceforge.plantuml.tim.builtin.RightAlign; import net.sourceforge.plantuml.tim.builtin.SetVariableValue; import net.sourceforge.plantuml.tim.builtin.Size; import net.sourceforge.plantuml.tim.builtin.SplitStr; @@ -217,6 +220,7 @@ private void addStandardFunctions(Defines defines) { functionsSet.addFunction(new JsonMerge()); functionsSet.addFunction(new JsonRemove()); functionsSet.addFunction(new JsonSet()); + functionsSet.addFunction(new LeftAlign()); functionsSet.addFunction(new Lighten()); functionsSet.addFunction(new LoadJson()); // functionsSet.addFunction(new LoadJsonLegacy()); @@ -237,6 +241,7 @@ private void addStandardFunctions(Defines defines) { functionsSet.addFunction(new RetrieveProcedure()); functionsSet.addFunction(new ReverseColor()); functionsSet.addFunction(new ReverseHsluvColor()); + functionsSet.addFunction(new RightAlign()); functionsSet.addFunction(new SetVariableValue()); functionsSet.addFunction(new Size()); functionsSet.addFunction(new SplitStr()); @@ -848,7 +853,7 @@ public String extractFromResultList(int n1) { sb.append(resultList.get(n1).getString()); resultList.remove(n1); if (resultList.size() > n1) - sb.append("\\n"); + sb.append(Jaws.BLOCK_E1_NEWLINE); } return sb.toString(); diff --git a/src/net/sourceforge/plantuml/tim/builtin/LeftAlign.java b/src/net/sourceforge/plantuml/tim/builtin/LeftAlign.java new file mode 100644 index 00000000000..e2ba1af9c0f --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/builtin/LeftAlign.java @@ -0,0 +1,64 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.tim.builtin; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.jaws.Jaws; +import net.sourceforge.plantuml.text.StringLocated; +import net.sourceforge.plantuml.tim.TContext; +import net.sourceforge.plantuml.tim.TFunctionSignature; +import net.sourceforge.plantuml.tim.TMemory; +import net.sourceforge.plantuml.tim.expression.TValue; + +public class LeftAlign extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%left_align", 0); + } + + @Override + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 0; + } + + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) { + return TValue.fromString("" + Jaws.BLOCK_E1_NEWLINE_LEFT_ALIGN); + } +} diff --git a/src/net/sourceforge/plantuml/tim/builtin/RightAlign.java b/src/net/sourceforge/plantuml/tim/builtin/RightAlign.java new file mode 100644 index 00000000000..745e59666a1 --- /dev/null +++ b/src/net/sourceforge/plantuml/tim/builtin/RightAlign.java @@ -0,0 +1,64 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2024, Arnaud Roques + * + * Project Info: https://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * https://plantuml.com/patreon (only 1$ per month!) + * https://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.tim.builtin; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.sourceforge.plantuml.jaws.Jaws; +import net.sourceforge.plantuml.text.StringLocated; +import net.sourceforge.plantuml.tim.TContext; +import net.sourceforge.plantuml.tim.TFunctionSignature; +import net.sourceforge.plantuml.tim.TMemory; +import net.sourceforge.plantuml.tim.expression.TValue; + +public class RightAlign extends SimpleReturnFunction { + + public TFunctionSignature getSignature() { + return new TFunctionSignature("%right_align", 0); + } + + @Override + public boolean canCover(int nbArg, Set namedArgument) { + return nbArg == 0; + } + + @Override + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, + Map named) { + return TValue.fromString("" + Jaws.BLOCK_E1_NEWLINE_RIGHT_ALIGN); + } +}