diff --git a/ui/src/main/java/io/xeres/ui/controller/chat/ChatListDragSelection.java b/ui/src/main/java/io/xeres/ui/controller/chat/ChatListDragSelection.java index 1690f579..830d3a6b 100644 --- a/ui/src/main/java/io/xeres/ui/controller/chat/ChatListDragSelection.java +++ b/ui/src/main/java/io/xeres/ui/controller/chat/ChatListDragSelection.java @@ -23,6 +23,7 @@ import io.xeres.ui.support.chat.ChatLine; import io.xeres.ui.support.clipboard.ClipboardUtils; import io.xeres.ui.support.util.TextFlowUtils; +import io.xeres.ui.support.util.TextFlowUtils.Options; import io.xeres.ui.support.util.TextSelectRange; import javafx.scene.Cursor; import javafx.scene.Node; @@ -319,21 +320,21 @@ private String getSelectionAsText() assert textFlow.getChildren().size() >= 3; - return TextFlowUtils.getTextFlowAsText(textFlow, textSelectRange.getStart(), textSelectRange.getEnd() + 1, 2); + return TextFlowUtils.getTextFlowAsText(textFlow, textSelectRange.getStart(), textSelectRange.getEnd() + 1, Options.SPACED_PREFIXES); } else { if (direction == Direction.UP) { return textFlows.reversed().stream() - .map(textFlow -> TextFlowUtils.getTextFlowAsText(textFlow, getOffsetFromSelectionMode())) + .map(textFlow -> TextFlowUtils.getTextFlowAsText(textFlow, getOffsetFromSelectionMode(), Options.SPACED_PREFIXES)) .collect(Collectors.joining("\n")); } else { return textFlows.stream() - .map(textFlow -> TextFlowUtils.getTextFlowAsText(textFlow, getOffsetFromSelectionMode())) + .map(textFlow -> TextFlowUtils.getTextFlowAsText(textFlow, getOffsetFromSelectionMode(), Options.SPACED_PREFIXES)) .collect(Collectors.joining("\n")); } } diff --git a/ui/src/main/java/io/xeres/ui/support/util/TextFlowDragSelection.java b/ui/src/main/java/io/xeres/ui/support/util/TextFlowDragSelection.java index 42a012ba..52cc3fa0 100644 --- a/ui/src/main/java/io/xeres/ui/support/util/TextFlowDragSelection.java +++ b/ui/src/main/java/io/xeres/ui/support/util/TextFlowDragSelection.java @@ -21,6 +21,7 @@ import io.micrometer.common.util.StringUtils; import io.xeres.ui.support.clipboard.ClipboardUtils; +import io.xeres.ui.support.util.TextFlowUtils.Options; import javafx.geometry.Point2D; import javafx.scene.Cursor; import javafx.scene.input.MouseEvent; @@ -90,7 +91,7 @@ public void release(MouseEvent e) public void copy() { - var text = TextFlowUtils.getTextFlowAsText(textFlow, textSelectRange.getStart(), textSelectRange.getEnd() + 1); + var text = TextFlowUtils.getTextFlowAsText(textFlow, textSelectRange.getStart(), textSelectRange.getEnd() + 1, Options.NONE); if (StringUtils.isNotBlank(text)) { ClipboardUtils.copyTextToClipboard(text); diff --git a/ui/src/main/java/io/xeres/ui/support/util/TextFlowUtils.java b/ui/src/main/java/io/xeres/ui/support/util/TextFlowUtils.java index 16893965..5d8aa35c 100644 --- a/ui/src/main/java/io/xeres/ui/support/util/TextFlowUtils.java +++ b/ui/src/main/java/io/xeres/ui/support/util/TextFlowUtils.java @@ -39,17 +39,24 @@ private TextFlowUtils() throw new UnsupportedOperationException("Utility class"); } + public enum Options + { + NONE, + SPACED_PREFIXES // This lacks flexibility but will do for now + } + /** * Returns a text flow as a string. * - * @param textFlow the text flow, not null + * @param textFlow the text flow, not null * @param beginIndex the beginning index, inclusive + * @param options the options * @return the string, not null */ - public static String getTextFlowAsText(TextFlow textFlow, int beginIndex) + public static String getTextFlowAsText(TextFlow textFlow, int beginIndex, Options options) { Objects.requireNonNull(textFlow); - return getTextFlowAsText(textFlow, beginIndex, getTextFlowCount(textFlow)); + return getTextFlowAsText(textFlow, beginIndex, getTextFlowCount(textFlow), options); } /** @@ -58,17 +65,12 @@ public static String getTextFlowAsText(TextFlow textFlow, int beginIndex) * @param textFlow the text flow, not null * @param beginIndex the beginning index, inclusive * @param endIndex the ending index, exclusive + * @param options the options * @return the string, not null */ - public static String getTextFlowAsText(TextFlow textFlow, int beginIndex, int endIndex) - { - var context = new Context(textFlow.getChildrenUnmodifiable(), beginIndex, endIndex, 0); - return context.getText(); - } - - public static String getTextFlowAsText(TextFlow textFlow, int beginIndex, int endIndex, int prefixNeedingSpace) + public static String getTextFlowAsText(TextFlow textFlow, int beginIndex, int endIndex, Options options) { - var context = new Context(textFlow.getChildrenUnmodifiable(), beginIndex, endIndex, prefixNeedingSpace); + var context = new Context(textFlow.getChildrenUnmodifiable(), beginIndex, endIndex, options == Options.SPACED_PREFIXES ? 2 : 0); return context.getText(); } diff --git a/ui/src/main/resources/view/about/about.fxml b/ui/src/main/resources/view/about/about.fxml index bc2a1427..5003348c 100644 --- a/ui/src/main/resources/view/about/about.fxml +++ b/ui/src/main/resources/view/about/about.fxml @@ -1,7 +1,7 @@