From 6c2aaf339f1148ed49ac44b5b5b2d4a57086350d Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Mon, 30 Sep 2024 22:33:51 +0530 Subject: [PATCH 1/3] Add spacing --- tui/src/filter.rs | 2 +- tui/src/running_command.rs | 2 +- tui/src/state.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tui/src/filter.rs b/tui/src/filter.rs index e6ff2cc2b..091b8f0ed 100644 --- a/tui/src/filter.rs +++ b/tui/src/filter.rs @@ -95,7 +95,7 @@ impl Filter { //Create the search bar widget let search_bar = Paragraph::new(display_text) - .block(Block::default().borders(Borders::ALL).title("Search")) + .block(Block::default().borders(Borders::ALL).title(" Search ")) .style(Style::default().fg(search_color)); //Render the search bar (First chunk of the screen) diff --git a/tui/src/running_command.rs b/tui/src/running_command.rs index 366a3dc36..d76a36e30 100644 --- a/tui/src/running_command.rs +++ b/tui/src/running_command.rs @@ -73,7 +73,7 @@ impl FloatContent for RunningCommand { title_line.push_span( Span::default() - .content(" press to close this window ") + .content(" Press to close this window ") .style(Style::default()), ); diff --git a/tui/src/state.rs b/tui/src/state.rs index 3448a3af4..9e12b7886 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -21,7 +21,7 @@ use ratatui::{ const MIN_WIDTH: u16 = 77; const MIN_HEIGHT: u16 = 19; -const TITLE: &str = concat!("Linux Toolbox - ", env!("BUILD_DATE")); +const TITLE: &str = concat!(" Linux Toolbox - ", env!("BUILD_DATE"), " "); const ACTIONS_GUIDE: &str = "List of important tasks performed by commands' names: D - disk modifications (ex. partitioning) (privileged) @@ -357,7 +357,7 @@ impl AppState { }; let title = if self.multi_select { - &format!("{} [Multi-Select]", TITLE) + &format!("{}[Multi-Select] ", TITLE) } else { TITLE }; @@ -367,7 +367,7 @@ impl AppState { #[cfg(not(feature = "tips"))] let bottom_title = ""; - let task_list_title = Line::from("Important Actions ").right_aligned(); + let task_list_title = Line::from(" Important Actions ").right_aligned(); // Create the list widget with items let list = List::new(items) @@ -694,5 +694,5 @@ fn get_random_tip() -> &'static str { let mut rng = rand::thread_rng(); let random_index = rng.gen_range(0..tips.len()); - tips[random_index] + Box::leak(format!(" {} ", tips[random_index]).into_boxed_str()) } From cc16c3e56def18cd8197b89e033a7255fb985cb4 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Tue, 1 Oct 2024 12:11:45 +0530 Subject: [PATCH 2/3] Use string instead of box::leak --- tui/src/state.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tui/src/state.rs b/tui/src/state.rs index 9e12b7886..b0b582adc 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -56,7 +56,7 @@ pub struct AppState { selected_commands: Vec, drawable: bool, #[cfg(feature = "tips")] - tip: &'static str, + tip: String, } pub enum Focus { @@ -363,7 +363,7 @@ impl AppState { }; #[cfg(feature = "tips")] - let bottom_title = Line::from(self.tip.bold().blue()).right_aligned(); + let bottom_title = Line::from(self.tip.clone().bold().blue()).right_aligned(); #[cfg(not(feature = "tips"))] let bottom_title = ""; @@ -686,13 +686,13 @@ impl AppState { const TIPS: &str = include_str!("../cool_tips.txt"); #[cfg(feature = "tips")] -fn get_random_tip() -> &'static str { +fn get_random_tip() -> String { let tips: Vec<&str> = TIPS.lines().collect(); if tips.is_empty() { - return ""; + return "".to_string(); } let mut rng = rand::thread_rng(); let random_index = rng.gen_range(0..tips.len()); - Box::leak(format!(" {} ", tips[random_index]).into_boxed_str()) + format!(" {} ", tips[random_index]) } From 5944d8443b896b4b0841efd7a38022e60aa8146e Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Tue, 1 Oct 2024 13:10:35 +0530 Subject: [PATCH 3/3] Update tui/src/state.rs Co-authored-by: Liam <33645555+lj3954@users.noreply.github.com> --- tui/src/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tui/src/state.rs b/tui/src/state.rs index b0b582adc..6132fea56 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -363,7 +363,7 @@ impl AppState { }; #[cfg(feature = "tips")] - let bottom_title = Line::from(self.tip.clone().bold().blue()).right_aligned(); + let bottom_title = Line::from(self.tip.as_str().bold().blue()).right_aligned(); #[cfg(not(feature = "tips"))] let bottom_title = "";