Skip to content

Commit

Permalink
renaming and reorganizing
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Jun 21, 2022
1 parent b47df8a commit 1f9d90e
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 399 deletions.
31 changes: 12 additions & 19 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl App {

// If the sort is now open, move left. Otherwise, if the proc sort was selected, force move right.
if pws.is_sort_open {
if let SortState::Sortable(st) = &pws.table_state.sort_state {
if let SortState::Sortable(st) = &pws.table.sort_state {
pws.sort_table_state.scroll_bar = 0;
pws.sort_table_state.current_scroll_position = st
.current_index
Expand All @@ -362,9 +362,7 @@ impl App {
};

if let Some(proc_widget_state) = self.proc_state.get_mut_widget_state(widget_id) {
if let SortState::Sortable(state) =
&mut proc_widget_state.table_state.sort_state
{
if let SortState::Sortable(state) = &mut proc_widget_state.table.sort_state {
state.toggle_order();
proc_widget_state.force_data_update();
}
Expand Down Expand Up @@ -1138,11 +1136,7 @@ impl App {
.widget_states
.get(&self.current_widget.widget_id)
{
if let Some(table_row) = pws
.table_data
.data
.get(pws.table_state.current_scroll_position)
{
if let Some(table_row) = pws.table_data.data.get(pws.table.current_scroll_position) {
if let Some(col_value) = table_row.row().get(ProcWidget::PROC_NAME_OR_CMD) {
let val = col_value.main_text().to_string();
if pws.is_using_command() {
Expand Down Expand Up @@ -1926,8 +1920,8 @@ impl App {
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
proc_widget_state.table_state.current_scroll_position = 0;
proc_widget_state.table_state.scroll_direction = ScrollDirection::Up;
proc_widget_state.table.current_scroll_position = 0;
proc_widget_state.table.scroll_direction = ScrollDirection::Up;
}
}
BottomWidgetType::ProcSort => {
Expand Down Expand Up @@ -1982,9 +1976,9 @@ impl App {
.proc_state
.get_mut_widget_state(self.current_widget.widget_id)
{
proc_widget_state.table_state.current_scroll_position =
proc_widget_state.table.current_scroll_position =
proc_widget_state.table_data.data.len().saturating_sub(1);
proc_widget_state.table_state.scroll_direction = ScrollDirection::Down;
proc_widget_state.table.scroll_direction = ScrollDirection::Down;
}
}
BottomWidgetType::ProcSort => {
Expand Down Expand Up @@ -2097,7 +2091,7 @@ impl App {
.get_mut_widget_state(self.current_widget.widget_id)
{
proc_widget_state
.table_state
.table
.update_position(num_to_change_by, proc_widget_state.table_data.data.len())
} else {
None
Expand Down Expand Up @@ -2587,7 +2581,7 @@ impl App {
.get_widget_state(self.current_widget.widget_id)
{
if let Some(visual_index) =
proc_widget_state.table_state.table_state.selected()
proc_widget_state.table.table_state.selected()
{
// If in tree mode, also check to see if this click is on
// the same entry as the already selected one - if it is,
Expand All @@ -2598,9 +2592,8 @@ impl App {
ProcWidgetMode::Tree { .. }
);

let previous_scroll_position = proc_widget_state
.table_state
.current_scroll_position;
let previous_scroll_position =
proc_widget_state.table.current_scroll_position;

let new_position = self.change_process_position(
offset_clicked_entry as i64 - visual_index as i64,
Expand Down Expand Up @@ -2687,7 +2680,7 @@ impl App {
.get_mut_widget_state(self.current_widget.widget_id)
{
if let SortState::Sortable(st) =
&mut proc_widget_state.table_state.sort_state
&mut proc_widget_state.table.sort_state
{
if st.try_select_location(x, y).is_some() {
proc_widget_state.force_data_update();
Expand Down
18 changes: 10 additions & 8 deletions src/app/widgets.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
pub mod process_table_widget;
pub use process_table_widget::*;
// FIXME: Move this outside along with components?

pub mod temperature_table_widget;
pub use temperature_table_widget::*;
pub mod process_table;
pub use process_table::*;

pub mod disk_table_widget;
pub use disk_table_widget::*;
pub mod temperature_table;
pub use temperature_table::*;

pub mod cpu_graph_widget;
pub use cpu_graph_widget::*;
pub mod disk_table;
pub use disk_table::*;

pub mod cpu_graph;
pub use cpu_graph::*;
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1f9d90e

Please sign in to comment.