From b22e891b7def964b8f4fce0ea11e983396a03a5b Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 24 Aug 2021 10:52:56 +0200 Subject: [PATCH] make select all, copy on transaction hex area copy untruncated transaction hex --- .../sparrow/control/TransactionHexArea.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java b/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java index 45ce3885..b0d1aae0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/TransactionHexArea.java @@ -5,6 +5,7 @@ import com.sparrowwallet.drongo.protocol.*; import javafx.application.Platform; import javafx.geometry.Point2D; import javafx.scene.control.ContextMenu; +import javafx.scene.control.IndexRange; import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.input.Clipboard; @@ -25,6 +26,7 @@ public class TransactionHexArea extends CodeArea { private static final int TRUNCATE_AT = 30000; private static final int SEGMENTS_INTERVAL = 250; + private String fullHex; private List previousSegmentList = new ArrayList<>(); public TransactionHexArea() { @@ -37,7 +39,7 @@ public class TransactionHexArea extends CodeArea { ByteArrayOutputStream baos = new ByteArrayOutputStream(); transaction.bitcoinSerializeToStream(baos); - String fullHex = Utils.bytesToHex(baos.toByteArray()); + fullHex = Utils.bytesToHex(baos.toByteArray()); String hex = fullHex; if(hex.length() > TRUNCATE_AT) { hex = hex.substring(0, TRUNCATE_AT); @@ -242,6 +244,18 @@ public class TransactionHexArea extends CodeArea { }; } + @Override + public void copy() { + IndexRange selection = getSelection(); + if(fullHex != null && selection.getLength() == getLength()) { + ClipboardContent content = new ClipboardContent(); + content.putString(fullHex); + Clipboard.getSystemClipboard().setContent(content); + } else { + super.copy(); + } + } + private static class TransactionSegment { public TransactionSegment(int start, int length, Integer index, Integer witnessIndex, String style) { this.start = start;