Skip to content

Commit

Permalink
chore: Add spacing before and after for tui titles (#706)
Browse files Browse the repository at this point in the history
* Add spacing

* Use string instead of box::leak

* Update tui/src/state.rs

Co-authored-by: Liam <[email protected]>

---------

Co-authored-by: Liam <[email protected]>
Co-authored-by: Chris Titus <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent ad678b2 commit 11336cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tui/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tui/src/running_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl FloatContent for RunningCommand {

title_line.push_span(
Span::default()
.content(" press <ENTER> to close this window ")
.content(" Press <ENTER> to close this window ")
.style(Style::default()),
);

Expand Down
16 changes: 8 additions & 8 deletions tui/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -61,7 +61,7 @@ pub struct AppState {
selected_commands: Vec<Rc<ListNode>>,
drawable: bool,
#[cfg(feature = "tips")]
tip: &'static str,
tip: String,
}

pub enum Focus {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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])
}

0 comments on commit 11336cf

Please sign in to comment.