[wallet] Clear UI before starting UI loop
Clears the UI once before starting the UI loop. On some terminals,
fragments of the previous screen text remain when starting the wallet.
@@ -65,8 +65,7 @@ pub fn run(app: App<CrosstermBackend<Stdout>>) -> Result<(), ExitCodes> {
crossterm_loop(app)
}
/// This is the main loop of the application UI using Crossterm based events
-fn crossterm_loop(app: App<CrosstermBackend<Stdout>>) -> Result<(), ExitCodes> {
- let mut app = app;
+fn crossterm_loop(mut app: App<CrosstermBackend<Stdout>>) -> Result<(), ExitCodes> {
let events = CrosstermEvents::new();
enable_raw_mode().map_err(|e| {
error!(target: LOG_TARGET, "Error enabling Raw Mode {}", e);
@@ -85,6 +84,11 @@ fn crossterm_loop(app: App<CrosstermBackend<Stdout>>) -> Result<(), ExitCodes> {
ExitCodes::InterfaceError
})?;
+ terminal.clear().map_err(|e| {
+ error!(target: LOG_TARGET, "Error clearing interface. {}", e);
+ ExitCodes::InterfaceError
+ })?;
+
loop {
terminal.draw(|f| app.draw(f)).map_err(|e| {
error!(target: LOG_TARGET, "Error drawing interface. {}", e);
@@ -117,6 +121,11 @@ fn crossterm_loop(app: App<CrosstermBackend<Stdout>>) -> Result<(), ExitCodes> {
}
}
+ terminal.clear().map_err(|e| {
+ error!(target: LOG_TARGET, "Error clearing interface. {}", e);
+ ExitCodes::InterfaceError
+ })?;
+
disable_raw_mode().map_err(|e| {
error!(target: LOG_TARGET, "Error disabling Raw Mode {}", e);
ExitCodes::InterfaceError
