mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
make select all, copy on transaction hex area copy untruncated transaction hex
This commit is contained in:
parent
57b3214c54
commit
b22e891b7d
1 changed files with 15 additions and 1 deletions
|
@ -5,6 +5,7 @@ import com.sparrowwallet.drongo.protocol.*;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.control.ContextMenu;
|
import javafx.scene.control.ContextMenu;
|
||||||
|
import javafx.scene.control.IndexRange;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.input.Clipboard;
|
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 TRUNCATE_AT = 30000;
|
||||||
private static final int SEGMENTS_INTERVAL = 250;
|
private static final int SEGMENTS_INTERVAL = 250;
|
||||||
|
|
||||||
|
private String fullHex;
|
||||||
private List<TransactionSegment> previousSegmentList = new ArrayList<>();
|
private List<TransactionSegment> previousSegmentList = new ArrayList<>();
|
||||||
|
|
||||||
public TransactionHexArea() {
|
public TransactionHexArea() {
|
||||||
|
@ -37,7 +39,7 @@ public class TransactionHexArea extends CodeArea {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
transaction.bitcoinSerializeToStream(baos);
|
transaction.bitcoinSerializeToStream(baos);
|
||||||
|
|
||||||
String fullHex = Utils.bytesToHex(baos.toByteArray());
|
fullHex = Utils.bytesToHex(baos.toByteArray());
|
||||||
String hex = fullHex;
|
String hex = fullHex;
|
||||||
if(hex.length() > TRUNCATE_AT) {
|
if(hex.length() > TRUNCATE_AT) {
|
||||||
hex = hex.substring(0, 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 {
|
private static class TransactionSegment {
|
||||||
public TransactionSegment(int start, int length, Integer index, Integer witnessIndex, String style) {
|
public TransactionSegment(int start, int length, Integer index, Integer witnessIndex, String style) {
|
||||||
this.start = start;
|
this.start = start;
|
||||||
|
|
Loading…
Reference in a new issue