mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
update default sort for temp and disk
This commit is contained in:
parent
863ae0059a
commit
9340044648
@ -247,8 +247,7 @@ pub fn create_collection_thread(
|
|||||||
sender: std::sync::mpsc::Sender<RuntimeEvent<AppMessages>>,
|
sender: std::sync::mpsc::Sender<RuntimeEvent<AppMessages>>,
|
||||||
control_receiver: std::sync::mpsc::Receiver<ThreadControlEvent>,
|
control_receiver: std::sync::mpsc::Receiver<ThreadControlEvent>,
|
||||||
termination_ctrl_lock: Arc<Mutex<bool>>, termination_ctrl_cvar: Arc<Condvar>,
|
termination_ctrl_lock: Arc<Mutex<bool>>, termination_ctrl_cvar: Arc<Condvar>,
|
||||||
app_config_fields: &app::AppConfig, filters: app::DataFilters,
|
app_config_fields: &app::AppConfig, filters: app::DataFilters, used_widget_set: UsedWidgets,
|
||||||
used_widget_set: UsedWidgets,
|
|
||||||
) -> std::thread::JoinHandle<()> {
|
) -> std::thread::JoinHandle<()> {
|
||||||
let temp_type = app_config_fields.temperature_type.clone();
|
let temp_type = app_config_fields.temperature_type.clone();
|
||||||
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
||||||
|
@ -5,6 +5,24 @@ use crate::tuine::{
|
|||||||
Bounds, DrawContext, Event, LayoutNode, Size, StateContext, Status, TmpComponent,
|
Bounds, DrawContext, Event, LayoutNode, Size, StateContext, Status, TmpComponent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MultiShortcutStep<Message, Child>
|
||||||
|
where
|
||||||
|
Child: TmpComponent<Message>,
|
||||||
|
{
|
||||||
|
NextStep(Event),
|
||||||
|
Action(
|
||||||
|
Box<
|
||||||
|
dyn Fn(
|
||||||
|
&mut Child,
|
||||||
|
&mut StateContext<'_>,
|
||||||
|
&DrawContext<'_>,
|
||||||
|
Event,
|
||||||
|
&mut Vec<Message>,
|
||||||
|
) -> Status,
|
||||||
|
>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
/// A [`Component`] to handle keyboard shortcuts and assign actions to them.
|
/// A [`Component`] to handle keyboard shortcuts and assign actions to them.
|
||||||
///
|
///
|
||||||
/// Inspired by [Flutter's approach](https://docs.flutter.dev/development/ui/advanced/actions_and_shortcuts).
|
/// Inspired by [Flutter's approach](https://docs.flutter.dev/development/ui/advanced/actions_and_shortcuts).
|
||||||
@ -26,6 +44,8 @@ where
|
|||||||
) -> Status,
|
) -> Status,
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
|
multi_shortcuts: FxHashMap<Event, MultiShortcutStep<Message, Child>>,
|
||||||
|
enabled_multi_shortcuts: FxHashMap<Event, MultiShortcutStep<Message, Child>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Message, Child> Shortcut<Message, Child>
|
impl<Message, Child> Shortcut<Message, Child>
|
||||||
@ -36,6 +56,8 @@ where
|
|||||||
Self {
|
Self {
|
||||||
child: Some(child),
|
child: Some(child),
|
||||||
shortcuts: Default::default(),
|
shortcuts: Default::default(),
|
||||||
|
multi_shortcuts: Default::default(),
|
||||||
|
enabled_multi_shortcuts: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ impl<Message> AppWidget for DiskTable<Message> {
|
|||||||
style,
|
style,
|
||||||
vec!["Disk", "Mount", "Used", "Free", "Total", "R/s", "W/s"],
|
vec!["Disk", "Mount", "Used", "Free", "Total", "R/s", "W/s"],
|
||||||
rows,
|
rows,
|
||||||
|
0,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,13 @@ impl<Message> SimpleTable<Message> {
|
|||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn build<C: Into<std::borrow::Cow<'static, str>>, R: Into<DataRow>>(
|
pub fn build<C: Into<std::borrow::Cow<'static, str>>, R: Into<DataRow>>(
|
||||||
ctx: &mut ViewContext<'_>, style: StyleSheet, columns: Vec<C>, data: Vec<R>,
|
ctx: &mut ViewContext<'_>, style: StyleSheet, columns: Vec<C>, data: Vec<R>,
|
||||||
|
sort_index: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let shortcut = Shortcut::with_child(TextTable::build(
|
let shortcut = Shortcut::with_child(TextTable::build(
|
||||||
ctx,
|
ctx,
|
||||||
TextTableProps::new(columns)
|
TextTableProps::new(columns)
|
||||||
.rows(data)
|
.rows(data)
|
||||||
.default_sort(SortType::Ascending(1))
|
.default_sort(SortType::Ascending(sort_index))
|
||||||
.style(text_table::StyleSheet {
|
.style(text_table::StyleSheet {
|
||||||
text: style.text,
|
text: style.text,
|
||||||
selected_text: style.selected_text,
|
selected_text: style.selected_text,
|
||||||
|
@ -33,7 +33,7 @@ impl<Message> AppWidget for TempTable<Message> {
|
|||||||
let rows = data.temp_table(config.temperature_type);
|
let rows = data.temp_table(config.temperature_type);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
inner: SimpleTable::build(ctx, style, vec!["Sensor", "Temp"], rows),
|
inner: SimpleTable::build(ctx, style, vec!["Sensor", "Temp"], rows, 0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user