From 3fc16fa554c225e82264cadcc0b179eb2c4181ca Mon Sep 17 00:00:00 2001 From: stringhandler Date: Wed, 31 Aug 2022 20:35:50 +0200 Subject: [PATCH] fix: remove window resize --- .../tari_base_node/src/commands/cli.rs | 21 ++----------------- .../tari_base_node/src/commands/cli_loop.rs | 4 ++-- applications/tari_base_node/src/config.rs | 3 --- applications/tari_base_node/src/main.rs | 2 +- common/config/presets/c_base_node.toml | 3 --- 5 files changed, 5 insertions(+), 28 deletions(-) diff --git a/applications/tari_base_node/src/commands/cli.rs b/applications/tari_base_node/src/commands/cli.rs index 45298a5ff3..d6f4b5499a 100644 --- a/applications/tari_base_node/src/commands/cli.rs +++ b/applications/tari_base_node/src/commands/cli.rs @@ -23,10 +23,7 @@ use std::io::stdout; use chrono::{Datelike, Utc}; -use crossterm::{ - execute, - terminal::{SetSize, SetTitle}, -}; +use crossterm::{execute, terminal::SetTitle}; use tari_app_utilities::consts; /// returns the top or bottom box line of the specified length @@ -106,17 +103,8 @@ fn multiline_find_display_length(lines: &str) -> usize { result } -/// Try to resize terminal to make sure the width is enough. -/// In case of error, just simply print out the error. -#[allow(clippy::cast_possible_truncation)] -fn resize_terminal_to_fit_the_box(width: usize, height: usize) { - if let Err(e) = execute!(stdout(), SetSize(width as u16, height as u16)) { - println!("Can't resize terminal to fit the box. Error: {}", e) - } -} - /// Prints a pretty banner on the console as well as the list of available commands -pub fn print_banner(commands: Vec, chunk_size: usize, resize_terminal: bool) { +pub fn print_banner(commands: Vec, chunk_size: usize) { let terminal_title = format!("Tari Base Node - Version {}", consts::APP_VERSION); if let Err(e) = execute!(stdout(), SetTitle(terminal_title.as_str())) { println!("Error setting terminal title. {}", e) @@ -191,13 +179,8 @@ pub fn print_banner(commands: Vec, chunk_size: usize, resize_terminal: b let rows = box_tabular_data_rows(command_data, row_cell_size, target_line_length, 10); // There are 24 fixed rows besides the possible changed "Commands" rows // and plus 2 more blank rows for better layout. - let height_to_resize = &rows.len() + 24 + 2; for row in rows { println!("{}", row); } println!("{}", box_line(target_line_length, false)); - - if resize_terminal { - resize_terminal_to_fit_the_box(target_line_length, height_to_resize); - } } diff --git a/applications/tari_base_node/src/commands/cli_loop.rs b/applications/tari_base_node/src/commands/cli_loop.rs index 6834850916..58f89e0b7b 100644 --- a/applications/tari_base_node/src/commands/cli_loop.rs +++ b/applications/tari_base_node/src/commands/cli_loop.rs @@ -79,8 +79,8 @@ impl CliLoop { /// /// ## Returns /// Doesn't return anything - pub async fn cli_loop(mut self, resize_terminal_on_startup: bool) { - cli::print_banner(self.commands.clone(), 3, resize_terminal_on_startup); + pub async fn cli_loop(mut self) { + cli::print_banner(self.commands.clone(), 3); if self.non_interactive { self.watch_loop_non_interactive().await; diff --git a/applications/tari_base_node/src/config.rs b/applications/tari_base_node/src/config.rs index 6175f02f5e..21fd61dfe2 100644 --- a/applications/tari_base_node/src/config.rs +++ b/applications/tari_base_node/src/config.rs @@ -130,8 +130,6 @@ pub struct BaseNodeConfig { pub metadata_auto_ping_interval: Duration, /// The state_machine config settings pub state_machine: BaseNodeStateMachineConfig, - /// Resize the CLI terminal on startup to a pre-defined size, or keep user settings - pub resize_terminal_on_startup: bool, /// Obscure GRPC error responses pub report_grpc_error: bool, } @@ -166,7 +164,6 @@ impl Default for BaseNodeConfig { buffer_rate_limit: 1_000, metadata_auto_ping_interval: Duration::from_secs(30), state_machine: Default::default(), - resize_terminal_on_startup: true, report_grpc_error: false, } } diff --git a/applications/tari_base_node/src/main.rs b/applications/tari_base_node/src/main.rs index f700964165..9a63982e7e 100644 --- a/applications/tari_base_node/src/main.rs +++ b/applications/tari_base_node/src/main.rs @@ -254,7 +254,7 @@ async fn run_node( } info!(target: LOG_TARGET, "Tari base node has STARTED"); - main_loop.cli_loop(config.base_node.resize_terminal_on_startup).await; + main_loop.cli_loop().await; ctx.wait_for_shutdown().await; diff --git a/common/config/presets/c_base_node.toml b/common/config/presets/c_base_node.toml index 86cf41961f..f497013be0 100644 --- a/common/config/presets/c_base_node.toml +++ b/common/config/presets/c_base_node.toml @@ -75,9 +75,6 @@ identity_file = "config/base_node_id_esmeralda.json" # Liveness meta data auto ping interval between peers (default = 30 s) #metadata_auto_ping_interval = 30 -# Resize the CLI terminal on startup to a pre-defined size, or keep user settings (default = true) -#resize_terminal_on_startup = true - # Obscure GRPC error responses (default = false) #report_grpc_error = false