fix sorttable

This commit is contained in:
ClementTsang 2025-10-03 03:35:15 -04:00
parent 8b4d3a9416
commit cd9be0f5af
No known key found for this signature in database
GPG Key ID: DC3B7867D8D97095
4 changed files with 18 additions and 16 deletions

View File

@ -325,7 +325,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 {
pws.sort_table.set_position(pws.table.sort_index());
pws.sort_table.0.set_position(pws.table.sort_index());
self.move_widget_selection(&WidgetDirection::Left);
} else if let BottomWidgetType::ProcSort = self.current_widget.widget_type {
self.move_widget_selection(&WidgetDirection::Right);
@ -1760,7 +1760,7 @@ impl App {
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 2)
{
proc_widget_state.sort_table.scroll_to_first();
proc_widget_state.sort_table.0.scroll_to_first();
}
}
BottomWidgetType::Temp => {
@ -1819,7 +1819,7 @@ impl App {
.proc_state
.get_mut_widget_state(self.current_widget.widget_id - 2)
{
proc_widget_state.sort_table.scroll_to_last();
proc_widget_state.sort_table.0.scroll_to_last();
}
}
BottomWidgetType::Temp => {
@ -1893,6 +1893,7 @@ impl App {
{
proc_widget_state
.sort_table
.0
.increment_position(num_to_change_by);
}
}
@ -2414,7 +2415,7 @@ impl App {
.get_widget_state(self.current_widget.widget_id - 2)
{
if let Some(visual_index) =
proc_widget_state.sort_table.ratatui_selected()
proc_widget_state.sort_table.0.ratatui_selected()
{
self.change_process_sort_position(
offset_clicked_entry as i64 - visual_index as i64,

View File

@ -317,7 +317,7 @@ impl Painter {
selection_state: SelectionState::new(app_state.is_expanded, is_on_widget),
};
pws.sort_table.draw(
pws.sort_table.0.draw(
f,
&draw_info,
app_state.widget_map.get_mut(&widget_id),

View File

@ -19,11 +19,13 @@ use crate::{
data::{ProcessData, StoredData},
},
canvas::components::data_table::{
Column, ColumnHeader, ColumnWidthBounds, DataTableComponent, DataTableColumn, DataTableProps,
DataTableStyling, SortColumn, SortDataTable, SortDataTableProps, SortOrder, SortsRow,
Column, ColumnHeader, ColumnWidthBounds, DataTableColumn, DataTableComponent,
DataTableProps, DataTableStyling, SortColumn, SortDataTable, SortDataTableProps, SortOrder,
SortsRow,
},
collection::processes::{Pid, ProcessHarvest},
options::config::style::Styles,
widgets::process_table::sort_table::SortTable,
};
/// ProcessSearchState only deals with process' search's current settings and
@ -142,7 +144,6 @@ pub(crate) enum ProcWidgetMode {
}
type ProcessTable = SortDataTable<ProcWidgetData, ProcColumn>;
type SortTable = DataTableComponent<Cow<'static, str>, SortTableColumn>;
type StringPidMap = HashMap<String, Vec<Pid>>;
fn make_column(column: ProcColumn) -> SortColumn<ProcColumn> {
@ -251,7 +252,7 @@ impl ProcWidgetState {
};
let styling = DataTableStyling::from_palette(palette);
DataTableComponent::new(COLUMNS, props, styling)
SortTable(DataTableComponent::new(COLUMNS, props, styling))
}
fn new_process_table(
@ -439,7 +440,7 @@ impl ProcWidgetState {
#[cfg(target_os = "linux")]
hide_k_threads: config.hide_k_threads,
};
table.sort_table.set_data(table.column_text());
table.sort_table.0.set_data(table.column_text());
table
}
@ -870,7 +871,7 @@ impl ProcWidgetState {
_ => unreachable!(),
}
self.sort_table.set_data(self.column_text());
self.sort_table.0.set_data(self.column_text());
self.force_data_update();
}
}
@ -887,7 +888,7 @@ impl ProcWidgetState {
_ => unreachable!(),
}
self.sort_table.set_data(self.column_text());
self.sort_table.0.set_data(self.column_text());
self.force_data_update();
}
}
@ -997,7 +998,7 @@ impl ProcWidgetState {
}
_ => unreachable!(),
}
self.sort_table.set_data(self.column_text());
self.sort_table.0.set_data(self.column_text());
self.force_rerender_and_update();
}
}
@ -1042,7 +1043,7 @@ impl ProcWidgetState {
_ => unreachable!(),
}
self.sort_table.set_data(self.column_text());
self.sort_table.0.set_data(self.column_text());
self.force_rerender_and_update();
}
}
@ -1125,7 +1126,7 @@ impl ProcWidgetState {
/// Sets the [`ProcWidgetState`]'s current sort index to whatever was in the
/// sort table if possible, then closes the sort table.
pub(crate) fn use_sort_table_value(&mut self) {
self.table.set_sort_index(self.sort_table.current_index());
self.table.set_sort_index(self.sort_table.0.current_index());
self.is_sort_open = false;
self.force_rerender_and_update();

View File

@ -4,7 +4,7 @@ use crate::canvas::components::data_table::{
ColumnHeader, DataTable, DataTableColumn, DataTableComponent, DataToCell,
};
pub struct SortTable(DataTableComponent<Cow<'static, str>, SortTableColumn>);
pub struct SortTable(pub DataTableComponent<Cow<'static, str>, SortTableColumn>);
impl DataTable<&'static str> for SortTable {
type HeaderType = SortTableColumn;