Skip to content

Commit

Permalink
bug: hide user column for non-unix
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed May 16, 2022
1 parent b65a910 commit 3032730
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/app/widgets/process_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,12 @@ impl ProcWidget {
pub const WPS: usize = 5;
pub const T_READ: usize = 6;
pub const T_WRITE: usize = 7;
#[cfg(target_family = "unix")]
pub const USER: usize = 8;
#[cfg(target_family = "unix")]
pub const STATE: usize = 9;
#[cfg(not(target_family = "unix"))]
pub const STATE: usize = 8;

pub fn init(
mode: ProcWidgetMode, is_case_sensitive: bool, is_match_whole_word: bool,
Expand Down Expand Up @@ -375,6 +379,7 @@ impl ProcWidget {
TableComponentColumn::new_hard(ProcWidgetColumn::WritePerSecond, 8),
TableComponentColumn::new_hard(ProcWidgetColumn::TotalRead, 8),
TableComponentColumn::new_hard(ProcWidgetColumn::TotalWrite, 8),
#[cfg(target_family = "unix")]
TableComponentColumn::new_soft(ProcWidgetColumn::User, Some(0.05)),
TableComponentColumn::new_hard(ProcWidgetColumn::State, 7),
];
Expand Down Expand Up @@ -1129,10 +1134,13 @@ mod test {
columns[ProcWidget::T_WRITE].header,
ProcWidgetColumn::TotalWrite
));
assert!(matches!(
columns[ProcWidget::USER].header,
ProcWidgetColumn::User
));
#[cfg(target_family = "unix")]
{
assert!(matches!(
columns[ProcWidget::USER].header,
ProcWidgetColumn::User
));
}
assert!(matches!(
columns[ProcWidget::STATE].header,
ProcWidgetColumn::State
Expand Down

0 comments on commit 3032730

Please sign in to comment.