diff options
author | Justin Martin <jaming@protonmail.com> | 2022-08-22 02:47:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 02:47:22 -0400 |
commit | 6e0bc960939d4c74343f83500cba2acbdac441c9 (patch) | |
tree | 66e3bd1f4c06f6d5b9aebd6a1e6b7281be05277e /src/canvas/widgets/mem_basic.rs | |
parent | 11657aa0abfeca5de17cbfe7c349fcf12e1d189e (diff) |
feature: Add zfs feature flag for arc memory (#784)
* freebsd clippy
* add arc support
* Code Review: moved runtime cfg checks to compile time and formatting
* remove compile platform checks
* add zfs feature flag to get_arc_data
Diffstat (limited to 'src/canvas/widgets/mem_basic.rs')
-rw-r--r-- | src/canvas/widgets/mem_basic.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/canvas/widgets/mem_basic.rs b/src/canvas/widgets/mem_basic.rs index ae2b7f1f..60f35f09 100644 --- a/src/canvas/widgets/mem_basic.rs +++ b/src/canvas/widgets/mem_basic.rs @@ -105,6 +105,41 @@ impl Painter { let mem_text = vec![ Spans::from(Span::styled(mem_label, self.colours.ram_style)), Spans::from(Span::styled(swap_label, self.colours.swap_style)), + #[cfg(feature = "zfs")] + { + let arc_data: &[(f64, f64)] = &app_state.converted_data.arc_data; + let arc_use_percentage = if let Some(arc) = arc_data.last() { + arc.1 + } else { + 0.0 + }; + let trimmed_arc_frac = if let Some((_label_percent, label_frac)) = + &app_state.converted_data.arc_labels + { + label_frac.trim() + } else { + EMPTY_MEMORY_FRAC_STRING + }; + let arc_bar_length = usize::from(draw_loc.width.saturating_sub(7)) + .saturating_sub(trimmed_arc_frac.len()); + let num_bars_arc = calculate_basic_use_bars(arc_use_percentage, arc_bar_length); + let arc_label = if app_state.basic_mode_use_percent { + format!( + "ARC[{}{}{:3.0}%]", + "|".repeat(num_bars_arc), + " ".repeat(arc_bar_length - num_bars_arc + trimmed_arc_frac.len() - 4), + arc_use_percentage.round() + ) + } else { + format!( + "ARC[{}{}{}]", + "|".repeat(num_bars_arc), + " ".repeat(arc_bar_length - num_bars_arc), + trimmed_arc_frac + ) + }; + Spans::from(Span::styled(arc_label, self.colours.arc_style)) + }, ]; f.render_widget( |