From bc8acdb9de210aee96aa6e086c9d3c3b4d948fe5 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sat, 10 Oct 2020 12:54:04 +0300 Subject: [PATCH] Switch to an in-house clearScreen to avoid problems with exception tracking --- beacon_chain/keystore_management.nim | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/beacon_chain/keystore_management.nim b/beacon_chain/keystore_management.nim index 89bf51932..56bf2d2db 100644 --- a/beacon_chain/keystore_management.nim +++ b/beacon_chain/keystore_management.nim @@ -605,13 +605,11 @@ proc pickPasswordAndSaveWallet(rng: var BrHmacDrbgContext, echo "\nWallet file successfully written to \"", outWalletFile, "\"" return ok WalletPathPair(wallet: wallet, path: outWalletFile) -proc safeEraseScreen() = - try: - stdout.eraseScreen - except IOError: - discard - - discard execShellCmd(when defined(windows): "cls" else: "clear") +when defined(windows): + proc clearScreen() {.importc("clrscr"), header: "conio.h".} +else: + template clearScreen = + echo "\e[1;1H\e[2J\e[3J" proc createWalletInteractively*( rng: var BrHmacDrbgContext, @@ -661,7 +659,7 @@ proc createWalletInteractively*( fatal "Failed to read a key from stdin", err = err.msg quit 1 - safeEraseScreen() + clearScreen() echoP "To confirm that you've saved the seed phrase, please enter the first and the " & "last three words of it. In case you've saved the seek phrase in your clipboard, " & @@ -687,7 +685,7 @@ proc createWalletInteractively*( else: quit 1 - safeEraseScreen() + clearScreen() let walletPath = ? pickPasswordAndSaveWallet(rng, config, mnemonic) return ok CreatedWallet(walletPath: walletPath, mnemonic: mnemonic)