mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
refactor: Add CPU load back
This commit is contained in:
parent
16babea202
commit
e89d46e10f
@ -12,6 +12,7 @@ use crate::{
|
|||||||
event::{ComponentEventResult, SelectionAction},
|
event::{ComponentEventResult, SelectionAction},
|
||||||
text_table::SimpleColumn,
|
text_table::SimpleColumn,
|
||||||
time_graph::TimeGraphData,
|
time_graph::TimeGraphData,
|
||||||
|
widgets::tui_stuff::BlockBuilder,
|
||||||
AppConfigFields, Component, DataCollection, TextTable, TimeGraph, Widget,
|
AppConfigFields, Component, DataCollection, TextTable, TimeGraph, Widget,
|
||||||
},
|
},
|
||||||
canvas::Painter,
|
canvas::Painter,
|
||||||
@ -251,8 +252,14 @@ impl Widget for CpuGraph {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let graph_block = self
|
let name = format!(
|
||||||
.block()
|
"{} ─ {:.2} {:.2} {:.2}",
|
||||||
|
self.get_pretty_name(),
|
||||||
|
self.load_avg_data[0],
|
||||||
|
self.load_avg_data[1],
|
||||||
|
self.load_avg_data[2],
|
||||||
|
);
|
||||||
|
let graph_block = BlockBuilder::new(name)
|
||||||
.selected(selected && matches!(&self.selected, CpuGraphSelection::Graph))
|
.selected(selected && matches!(&self.selected, CpuGraphSelection::Graph))
|
||||||
.show_esc(expanded)
|
.show_esc(expanded)
|
||||||
.build(painter, graph_block_area);
|
.build(painter, graph_block_area);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
text::Span,
|
text::Span,
|
||||||
@ -11,19 +13,19 @@ pub struct BlockBuilder {
|
|||||||
borders: Borders,
|
borders: Borders,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
show_esc: bool,
|
show_esc: bool,
|
||||||
name: &'static str,
|
name: Cow<'static, str>,
|
||||||
hide_title: bool,
|
hide_title: bool,
|
||||||
extra_text: Option<String>,
|
extra_text: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockBuilder {
|
impl BlockBuilder {
|
||||||
/// Creates a new [`BlockBuilder`] with the name of block.
|
/// Creates a new [`BlockBuilder`] with the name of block.
|
||||||
pub fn new(name: &'static str) -> Self {
|
pub fn new<S: Into<Cow<'static, str>>>(name: S) -> Self {
|
||||||
Self {
|
Self {
|
||||||
borders: Borders::ALL,
|
borders: Borders::ALL,
|
||||||
selected: false,
|
selected: false,
|
||||||
show_esc: false,
|
show_esc: false,
|
||||||
name,
|
name: name.into(),
|
||||||
hide_title: false,
|
hide_title: false,
|
||||||
extra_text: None,
|
extra_text: None,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user