Improve Gauge usage
This commit is contained in:
parent
76b22fed4b
commit
c8e86dcea4
|
@ -6,9 +6,8 @@ use tool_helper::Error;
|
|||
use tui::{
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
symbols,
|
||||
text::{Span, Spans},
|
||||
widgets::{Block, Borders, BorderType, LineGauge, Paragraph, Tabs}
|
||||
widgets::{Block, Borders, BorderType, Gauge, Paragraph, Tabs}
|
||||
};
|
||||
|
||||
pub type EventReceiver = std::sync::mpsc::Receiver<Event<crossterm::event::KeyEvent>>;
|
||||
|
@ -196,16 +195,15 @@ impl ConsoleUI {
|
|||
frame.render_widget(mem_gauge, frames[1]);
|
||||
}
|
||||
|
||||
fn create_overall_mem_gauge<'a>(highest_adr: u64) -> LineGauge<'a> {
|
||||
fn create_overall_mem_gauge<'a>(highest_adr: u64) -> Gauge<'a> {
|
||||
const RAM_TOP:u64 = ConsoleUIData::HIGHEST_RAM_ADDRESS & !ConsoleUIData::RAM_BASE_ADDRESS;
|
||||
|
||||
let highest_adr_masked = highest_adr & !ConsoleUIData::RAM_BASE_ADDRESS;
|
||||
let adr_ratio = (highest_adr_masked as f64)/RAM_TOP as f64;
|
||||
|
||||
LineGauge::default().block(Block::default().borders(Borders::ALL)
|
||||
Gauge::default().block(Block::default().borders(Borders::ALL)
|
||||
.title(format!("Memory Usage: {}% [0x{:x}/0x{:x}]", adr_ratio*100.0f64, highest_adr, ConsoleUIData::HIGHEST_RAM_ADDRESS)))
|
||||
.gauge_style(Style::default().fg(Color::White).bg(Color::Black).add_modifier(Modifier::BOLD))
|
||||
.line_set(symbols::line::THICK)
|
||||
.gauge_style(Style::default().fg(Color::Cyan).bg(Color::Black).add_modifier(Modifier::BOLD))
|
||||
.ratio(adr_ratio)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue