Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove window resize #4593

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions applications/tari_base_node/src/commands/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String>, chunk_size: usize, resize_terminal: bool) {
pub fn print_banner(commands: Vec<String>, 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)
Expand Down Expand Up @@ -191,13 +179,8 @@ pub fn print_banner(commands: Vec<String>, 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);
}
}
4 changes: 2 additions & 2 deletions applications/tari_base_node/src/commands/cli_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions applications/tari_base_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_base_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 0 additions & 3 deletions common/config/presets/c_base_node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down