bug: fix CPU 'all' label missing on small sizes (#953)
Fixes the "All" label being missing on small windows.
This commit is contained in:
parent
0093a45be9
commit
8f9097b90c
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## Bug Fixes
|
||||
|
||||
- [#952](https://github.com/ClementTsang/bottom/pull/952): Partially fix battery text getting cut off in small windows.
|
||||
- [#953](https://github.com/ClementTsang/bottom/pull/953): Fix CPU widget's 'all' label being missing on small sizes.
|
||||
|
||||
## Changes
|
||||
|
||||
|
|
|
@ -221,11 +221,7 @@ where
|
|||
.iter()
|
||||
.zip(&self.state.calculated_widths)
|
||||
.filter_map(|(column, &width)| {
|
||||
if width > 0 {
|
||||
data_row.to_cell(column.inner(), width)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
data_row.to_cell(column.inner(), width)
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ impl CpuWidgetTableData {
|
|||
|
||||
impl DataToCell<CpuWidgetColumn> for CpuWidgetTableData {
|
||||
fn to_cell<'a>(&'a self, column: &CpuWidgetColumn, calculated_width: u16) -> Option<Text<'a>> {
|
||||
const CPU_HIDE_BREAKPOINT: u16 = 5;
|
||||
const CPU_TRUNCATE_BREAKPOINT: u16 = 5;
|
||||
|
||||
// This is a bit of a hack, but apparently we can avoid having to do any fancy checks
|
||||
// of showing the "All" on a specific column if the other is hidden by just always
|
||||
|
@ -88,22 +88,22 @@ impl DataToCell<CpuWidgetColumn> for CpuWidgetTableData {
|
|||
// it is too small.
|
||||
match &self {
|
||||
CpuWidgetTableData::All => match column {
|
||||
CpuWidgetColumn::CPU => Some(truncate_to_text("All", calculated_width)),
|
||||
CpuWidgetColumn::CPU => Some("All".into()),
|
||||
CpuWidgetColumn::Use => None,
|
||||
},
|
||||
CpuWidgetTableData::Entry {
|
||||
data_type,
|
||||
last_entry,
|
||||
} => match column {
|
||||
CpuWidgetColumn::CPU => {
|
||||
if calculated_width == 0 {
|
||||
None
|
||||
} else {
|
||||
match data_type {
|
||||
} => {
|
||||
if calculated_width == 0 {
|
||||
None
|
||||
} else {
|
||||
match column {
|
||||
CpuWidgetColumn::CPU => match data_type {
|
||||
CpuDataType::Avg => Some(truncate_to_text("AVG", calculated_width)),
|
||||
CpuDataType::Cpu(index) => {
|
||||
let index_str = index.to_string();
|
||||
let text = if calculated_width < CPU_HIDE_BREAKPOINT {
|
||||
let text = if calculated_width < CPU_TRUNCATE_BREAKPOINT {
|
||||
truncate_to_text(&index_str, calculated_width)
|
||||
} else {
|
||||
truncate_to_text(
|
||||
|
@ -114,14 +114,14 @@ impl DataToCell<CpuWidgetColumn> for CpuWidgetTableData {
|
|||
|
||||
Some(text)
|
||||
}
|
||||
}
|
||||
},
|
||||
CpuWidgetColumn::Use => Some(truncate_to_text(
|
||||
&format!("{:.0}%", last_entry.round()),
|
||||
calculated_width,
|
||||
)),
|
||||
}
|
||||
}
|
||||
CpuWidgetColumn::Use => Some(truncate_to_text(
|
||||
&format!("{:.0}%", last_entry.round()),
|
||||
calculated_width,
|
||||
)),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,10 @@ impl ColumnHeader for DiskWidgetColumn {
|
|||
|
||||
impl DataToCell<DiskWidgetColumn> for DiskWidgetData {
|
||||
fn to_cell<'a>(&'a self, column: &DiskWidgetColumn, calculated_width: u16) -> Option<Text<'a>> {
|
||||
if calculated_width == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let text = match column {
|
||||
DiskWidgetColumn::Disk => truncate_to_text(&self.name, calculated_width),
|
||||
DiskWidgetColumn::Mount => truncate_to_text(&self.mount_point, calculated_width),
|
||||
|
|
|
@ -221,6 +221,10 @@ impl ProcWidgetData {
|
|||
|
||||
impl DataToCell<ProcColumn> for ProcWidgetData {
|
||||
fn to_cell<'a>(&'a self, column: &ProcColumn, calculated_width: u16) -> Option<Text<'a>> {
|
||||
if calculated_width == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
// TODO: Optimize the string allocations here...
|
||||
// TODO: Also maybe just pull in the to_string call but add a variable for the differences.
|
||||
Some(truncate_to_text(
|
||||
|
|
|
@ -17,6 +17,10 @@ impl ColumnHeader for SortTableColumn {
|
|||
|
||||
impl DataToCell<SortTableColumn> for &'static str {
|
||||
fn to_cell<'a>(&'a self, _column: &SortTableColumn, calculated_width: u16) -> Option<Text<'a>> {
|
||||
if calculated_width == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(truncate_to_text(self, calculated_width))
|
||||
}
|
||||
|
||||
|
@ -30,6 +34,10 @@ impl DataToCell<SortTableColumn> for &'static str {
|
|||
|
||||
impl DataToCell<SortTableColumn> for Cow<'static, str> {
|
||||
fn to_cell<'a>(&'a self, _column: &SortTableColumn, calculated_width: u16) -> Option<Text<'a>> {
|
||||
if calculated_width == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(truncate_to_text(self, calculated_width))
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,10 @@ impl TempWidgetData {
|
|||
|
||||
impl DataToCell<TempWidgetColumn> for TempWidgetData {
|
||||
fn to_cell<'a>(&'a self, column: &TempWidgetColumn, calculated_width: u16) -> Option<Text<'a>> {
|
||||
if calculated_width == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(match column {
|
||||
TempWidgetColumn::Sensor => truncate_to_text(&self.sensor, calculated_width),
|
||||
TempWidgetColumn::Temp => truncate_to_text(&self.temperature(), calculated_width),
|
||||
|
|
Loading…
Reference in New Issue