From 11336cf9f182123624190e3bb9e6d1f0d8cdeb89 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Fri, 1 Nov 2024 00:44:17 +0530 Subject: [PATCH] chore: Add spacing before and after for tui titles (#706) * Add spacing * Use string instead of box::leak * Update tui/src/state.rs Co-authored-by: Liam <33645555+lj3954@users.noreply.github.com> --------- Co-authored-by: Liam <33645555+lj3954@users.noreply.github.com> Co-authored-by: Chris Titus --- tui/src/filter.rs | 2 +- tui/src/running_command.rs | 2 +- tui/src/state.rs | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tui/src/filter.rs b/tui/src/filter.rs index 20192b03..cd6063fc 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 89daa755..f2471778 100644 --- a/tui/src/running_command.rs +++ b/tui/src/running_command.rs @@ -74,7 +74,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 fbd21ac8..a07bf178 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -24,7 +24,7 @@ use temp_dir::TempDir; const MIN_WIDTH: u16 = 100; const MIN_HEIGHT: u16 = 25; -const TITLE: &str = concat!("Linux Toolbox - ", env!("CARGO_PKG_VERSION")); +const TITLE: &str = concat!(" Linux Toolbox - ", env!("CARGO_PKG_VERSION"), " "); const ACTIONS_GUIDE: &str = "List of important tasks performed by commands' names: D - disk modifications (ex. partitioning) (privileged) @@ -61,7 +61,7 @@ pub struct AppState { selected_commands: Vec>, drawable: bool, #[cfg(feature = "tips")] - tip: &'static str, + tip: String, } pub enum Focus { @@ -375,17 +375,17 @@ impl AppState { }; let title = if self.multi_select { - &format!("{} [Multi-Select]", TITLE) + &format!("{}[Multi-Select] ", TITLE) } else { TITLE }; #[cfg(feature = "tips")] - let bottom_title = Line::from(self.tip.bold().blue()).right_aligned(); + let bottom_title = Line::from(self.tip.as_str().bold().blue()).right_aligned(); #[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) @@ -824,13 +824,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()); - tips[random_index] + format!(" {} ", tips[random_index]) }