refactor: help box description from TOML
This commit is contained in:
+15
-20
@@ -35,6 +35,7 @@ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8
|
||||
const NAME: &str = env!("CARGO_PKG_NAME");
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
const REPO: &str = env!("CARGO_PKG_REPOSITORY");
|
||||
const DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION");
|
||||
const ORANGE: Color = Color::Rgb(255, 178, 36);
|
||||
const MARGIN: &str = " ";
|
||||
|
||||
@@ -45,7 +46,9 @@ fn generate_block<'a>(
|
||||
app_data: &Arc<Mutex<AppData>>,
|
||||
selected_panel: &SelectablePanel,
|
||||
) -> Block<'a> {
|
||||
let mut block = Block::default().borders(Borders::ALL).border_type(BorderType::Rounded);
|
||||
let mut block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded);
|
||||
|
||||
if let Some(panel) = selectable_panel {
|
||||
let title = match panel {
|
||||
@@ -66,8 +69,7 @@ fn generate_block<'a>(
|
||||
// let selected_style = Style::default().fg(Color::LightCyan);
|
||||
// let selected_border = BorderType::Plain;
|
||||
// let selected_border = BorderType::Rounded;
|
||||
block = block
|
||||
.border_style(Style::default().fg(Color::LightCyan));
|
||||
block = block.border_style(Style::default().fg(Color::LightCyan));
|
||||
// .border_type(BorderType::Rounded);
|
||||
}
|
||||
}
|
||||
@@ -173,7 +175,12 @@ pub fn draw_containers<B: Backend>(
|
||||
state_style,
|
||||
),
|
||||
Span::styled(
|
||||
format!("{}{:>width$}", MARGIN, i.id.chars().take(8).collect::<String>(), width = widths.id.1),
|
||||
format!(
|
||||
"{}{:>width$}",
|
||||
MARGIN,
|
||||
i.id.chars().take(8).collect::<String>(),
|
||||
width = widths.id.1
|
||||
),
|
||||
blue,
|
||||
),
|
||||
Span::styled(
|
||||
@@ -386,15 +393,8 @@ pub fn draw_heading_bar<B: Backend>(
|
||||
.push_str(format!("{}{:>width$}", MARGIN, columns.cpu.0, width = columns.cpu.1).as_str());
|
||||
column_headings
|
||||
.push_str(format!("{}{:>width$}", MARGIN, columns.mem.0, width = columns.mem.1).as_str());
|
||||
column_headings.push_str(
|
||||
format!(
|
||||
"{}{:>width$}",
|
||||
MARGIN,
|
||||
columns.id.0,
|
||||
width = columns.id.1
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
column_headings
|
||||
.push_str(format!("{}{:>width$}", MARGIN, columns.id.0, width = columns.id.1).as_str());
|
||||
column_headings.push_str(
|
||||
format!(
|
||||
"{}{:>width$}",
|
||||
@@ -471,7 +471,7 @@ pub fn draw_heading_bar<B: Backend>(
|
||||
pub fn draw_help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
||||
let title = format!(" {} ", VERSION);
|
||||
|
||||
let description_text = String::from("\n A basic docker container information viewer and controller");
|
||||
let description_text = format!("\n{}", DESCRIPTION);
|
||||
|
||||
let mut help_text = String::from("\n ( tab ) or ( alt+tab ) to change panels");
|
||||
help_text.push_str("\n ( ↑ ↓ ← → ) mto change selected line");
|
||||
@@ -480,14 +480,11 @@ pub fn draw_help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
||||
help_text.push_str("\n ( m ) to toggle mouse capture - if disabled, text on screen can be selected & copied, but mouse clicks get disabled");
|
||||
help_text.push_str("\n ( q ) to quit at any time");
|
||||
help_text.push_str("\n mouse scrolling & clicking also available");
|
||||
help_text
|
||||
.push_str("\n\n currenty an early work in progress, all and any input appreciated");
|
||||
help_text.push_str("\n\n currenty an early work in progress, all and any input appreciated");
|
||||
help_text.push_str(format!("\n {}", REPO.trim()).as_str());
|
||||
|
||||
let mut max_line_width = 0;
|
||||
|
||||
|
||||
|
||||
let all_text = format!("{}{}{}", NAME_TEXT, description_text, help_text);
|
||||
|
||||
all_text.lines().into_iter().for_each(|line| {
|
||||
@@ -508,7 +505,6 @@ pub fn draw_help_box<B: Backend>(f: &mut Frame<'_, B>) {
|
||||
.block(Block::default())
|
||||
.alignment(Alignment::Center);
|
||||
|
||||
|
||||
let description_paragrpah = Paragraph::new(description_text.as_str())
|
||||
.style(Style::default().bg(Color::Magenta).fg(Color::Black))
|
||||
.block(Block::default())
|
||||
@@ -646,7 +642,6 @@ pub fn draw_info<B: Backend>(f: &mut Frame<'_, B>, text: String) {
|
||||
|
||||
/// draw a box in the center of the screen, based on max line width + number of lines
|
||||
fn draw_popup(text_lines: u16, text_width: u16, r: Rect, box_location: BoxLocation) -> Rect {
|
||||
|
||||
// Make sure blank_space can't be an negative, as will crash
|
||||
let blank_vertical = if r.height > text_lines {
|
||||
(r.height - text_lines) / 2
|
||||
|
||||
Reference in New Issue
Block a user