mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 12:26:45 +00:00
truncate loading log and avoid automatic scrolling to the right
This commit is contained in:
parent
ec131bb8da
commit
deb47ca002
2 changed files with 10 additions and 3 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
|||
Subproject commit 87b5f992d085efac64e7466af4906f9d1691fc8a
|
||||
Subproject commit 6b89a0c5ea7a63e1b410abe9963f20ce83763798
|
|
@ -35,6 +35,7 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
private static final Logger log = LoggerFactory.getLogger(TransactionsController.class);
|
||||
|
||||
private static final DateFormat LOG_DATE_FORMAT = new SimpleDateFormat("[MMM dd HH:mm:ss]");
|
||||
private static final int LOADING_LOG_MAX_CHARS = 10000;
|
||||
|
||||
@FXML
|
||||
private CopyableCoinLabel balance;
|
||||
|
@ -132,8 +133,14 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
Platform.runLater(() -> {
|
||||
int lastLineStart = loadingLog.getText().lastIndexOf("\n");
|
||||
if(lastLineStart < 0 || !loadingLog.getText().substring(lastLineStart).equals(logLine)) {
|
||||
loadingLog.appendText(logLine);
|
||||
loadingLog.setScrollLeft(0);
|
||||
if(loadingLog.getLength() > LOADING_LOG_MAX_CHARS) {
|
||||
int start = loadingLog.getText().indexOf('\n', loadingLog.getLength() - LOADING_LOG_MAX_CHARS);
|
||||
loadingLog.replaceText(0, loadingLog.getLength(), "[truncated]" + loadingLog.getText().substring(start > -1 ? start : 0, loadingLog.getLength()) + logLine);
|
||||
} else {
|
||||
loadingLog.appendText(logLine);
|
||||
}
|
||||
|
||||
loadingLog.positionCaret(loadingLog.getLength() - logLine.length() + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue