summaryrefslogtreecommitdiffstats
path: root/src/app/widgets/bottom_widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/widgets/bottom_widgets')
-rw-r--r--src/app/widgets/bottom_widgets/carousel.rs25
-rw-r--r--src/app/widgets/bottom_widgets/empty.rs8
-rw-r--r--src/app/widgets/bottom_widgets/process.rs20
3 files changed, 39 insertions, 14 deletions
diff --git a/src/app/widgets/bottom_widgets/carousel.rs b/src/app/widgets/bottom_widgets/carousel.rs
index 92d3614c..3788cf97 100644
--- a/src/app/widgets/bottom_widgets/carousel.rs
+++ b/src/app/widgets/bottom_widgets/carousel.rs
@@ -12,14 +12,15 @@ use tui::{
use crate::{
app::{
- does_bound_intersect_coordinate, event::ComponentEventResult, Component, SelectableType,
- Widget,
+ does_bound_intersect_coordinate,
+ event::{ComponentEventResult, SelectionAction},
+ Component, Widget,
},
canvas::Painter,
options::layout_options::LayoutRule,
};
-/// A container that "holds"" multiple [`BottomWidget`]s through their [`NodeId`]s.
+/// A container that "holds" multiple [`BottomWidget`]s through their [`NodeId`]s.
#[derive(PartialEq, Eq)]
pub struct Carousel {
index: usize,
@@ -109,7 +110,7 @@ impl Carousel {
.direction(tui::layout::Direction::Vertical)
.split(area);
- self.set_bounds(split_area[0]);
+ self.set_bounds(area);
if let Some((_prev_id, prev_element_name)) = self.get_prev() {
let prev_arrow_text = Spans::from(Span::styled(
@@ -198,11 +199,15 @@ impl Widget for Carousel {
self.height
}
- fn selectable_type(&self) -> SelectableType {
- if let Some(node) = self.get_currently_selected() {
- SelectableType::Redirect(node)
- } else {
- SelectableType::Unselectable
- }
+ fn handle_widget_selection_left(&mut self) -> SelectionAction {
+ // Override to move to the left widget
+ self.decrement_index();
+ SelectionAction::Handled
+ }
+
+ fn handle_widget_selection_right(&mut self) -> SelectionAction {
+ // Override to move to the right widget
+ self.increment_index();
+ SelectionAction::Handled
}
}
diff --git a/src/app/widgets/bottom_widgets/empty.rs b/src/app/widgets/bottom_widgets/empty.rs
index 4c33523b..e444ac2b 100644
--- a/src/app/widgets/bottom_widgets/empty.rs
+++ b/src/app/widgets/bottom_widgets/empty.rs
@@ -1,7 +1,7 @@
use tui::layout::Rect;
use crate::{
- app::{Component, Widget},
+ app::{Component, SelectableType, Widget},
options::layout_options::LayoutRule,
};
@@ -35,8 +35,6 @@ impl Empty {
impl Component for Empty {
fn bounds(&self) -> Rect {
- // TODO: Maybe think of how to store this without making it available for clicking. Separate bounds out to the layout? Might
- // need to keep the bounds calculations for some components, so maybe implement it specifically for them.
Rect::default()
}
@@ -55,4 +53,8 @@ impl Widget for Empty {
fn height(&self) -> LayoutRule {
self.height
}
+
+ fn selectable_type(&self) -> SelectableType {
+ SelectableType::Unselectable
+ }
}
diff --git a/src/app/widgets/bottom_widgets/process.rs b/src/app/widgets/bottom_widgets/process.rs
index 8a704848..3851bfcd 100644
--- a/src/app/widgets/bottom_widgets/process.rs
+++ b/src/app/widgets/bottom_widgets/process.rs
@@ -984,6 +984,24 @@ impl ProcessManager {
ComponentEventResult::Signal(ReturnSignal::Update)
}
+ fn toggle_memory(&mut self) -> ComponentEventResult {
+ if matches!(
+ self.process_table.columns()[3].sort_type,
+ ProcessSortType::MemPercent
+ ) {
+ self.process_table
+ .set_column(ProcessSortColumn::new(ProcessSortType::Mem), 3);
+ } else {
+ self.process_table
+ .set_column(ProcessSortColumn::new(ProcessSortType::MemPercent), 3);
+ }
+
+ // Invalidate row cache.
+ self.process_table.invalidate_cached_columns(); // TODO: This should be automatically called somehow after sets/removes to avoid forgetting it - maybe do a queue system?
+
+ ComponentEventResult::Signal(ReturnSignal::Update)
+ }
+
fn hide_sort(&mut self) {
self.show_sort = false;
if let ProcessManagerSelection::Sort = self.selected {
@@ -1081,7 +1099,7 @@ impl Component for ProcessManager {
return self.open_search();
}
KeyCode::Char('%') => {
- // Handle switching memory usage type
+ return self.toggle_memory();
}
KeyCode::Char('+') => {
// Expand a branch