summaryrefslogtreecommitdiffstats
path: root/src/options.rs
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-08-15 17:35:49 -0700
committerGitHub <noreply@github.com>2020-08-15 20:35:49 -0400
commitf3897f0538f90c682b96bc340c3c05e80be10b2d (patch)
treef24673d4d5702e48b9d3d1889f7498c97ac238a1 /src/options.rs
parent84f63f2f8306382dbf5cab819589161bf0b7c093 (diff)
feature: Allow sorting by any column
This feature allows any column to be sortable. This also adds: - Inverting sort for current column with `I` - Invoking a sort widget with `s` or `F6`. Close with same key or esc. And: - A bugfix in regards the basic menu and battery widget - A lot of refactoring
Diffstat (limited to 'src/options.rs')
-rw-r--r--src/options.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/options.rs b/src/options.rs
index 634a478f..81ac4c99 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -180,8 +180,7 @@ pub fn build_app(
battery_state_map
.insert(widget.widget_id, BatteryWidgetState::default());
}
- Empty | BasicCpu | BasicMem | BasicNet | BasicTables | ProcSearch
- | CpuLegend => {}
+ _ => {}
}
}
}
@@ -262,7 +261,17 @@ pub fn get_widget_layout(
let bottom_layout = if get_use_basic_mode(matches, config) {
default_widget_id = DEFAULT_WIDGET_ID;
BottomLayout::init_basic_default(get_use_battery(matches, config))
- } else if let Some(rows) = &config.row {
+ } else {
+ let ref_row: Vec<Row>; // Required to handle reference
+ let rows = match &config.row {
+ Some(r) => r,
+ None => {
+ // This cannot (like it really shouldn't) fail!
+ ref_row = toml::from_str::<Config>(DEFAULT_LAYOUT)?.row.unwrap();
+ &ref_row
+ }
+ };
+
let mut iter_id = 0; // A lazy way of forcing unique IDs *shrugs*
let mut total_height_ratio = 0;
@@ -286,15 +295,14 @@ pub fn get_widget_layout(
// Confirm that we have at least ONE widget - if not, error out!
if iter_id > 0 {
ret_bottom_layout.get_movement_mappings();
+ // debug!("Bottom layout: {:#?}", ret_bottom_layout);
+
ret_bottom_layout
} else {
return Err(error::BottomError::ConfigError(
"invalid layout config: please have at least one widget.".to_string(),
));
}
- } else {
- default_widget_id = DEFAULT_WIDGET_ID;
- BottomLayout::init_default(left_legend, get_use_battery(matches, config))
};
Ok((bottom_layout, default_widget_id))