summaryrefslogtreecommitdiffstats
path: root/src/options.rs
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-08-29 18:54:18 -0400
committerGitHub <noreply@github.com>2020-08-29 18:54:18 -0400
commit3d2fc76aa24047deb167768940c5969d2bb2a595 (patch)
tree9732b15a1570a83ffc7fa0db4d78773ceda30dd6 /src/options.rs
parentb6363096b416ddbe8f4a207cdd896194ba3e6e95 (diff)
feature: Add mouse click support for moving between widgets (#208)
Adds mouse support to the application, to move between widgets and click on elements. List of things to added: - Click to move between widgets - Click to move between widgets in basic mode - Click on widget entries - Ability to disable mouse if you don't like it, I guess
Diffstat (limited to 'src/options.rs')
-rw-r--r--src/options.rs60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/options.rs b/src/options.rs
index d772ed9e..41059f9c 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -42,6 +42,7 @@ pub struct ConfigFlags {
pub use_old_network_legend: Option<bool>,
pub hide_table_gap: Option<bool>,
pub battery: Option<bool>,
+ pub disable_click: Option<bool>,
}
#[derive(Default, Deserialize)]
@@ -192,11 +193,19 @@ pub fn build_app(
currently_displayed_widget_type: initial_widget_type,
currently_displayed_widget_id: initial_widget_id,
widget_id: 100,
+ left_tlc: None,
+ left_brc: None,
+ right_tlc: None,
+ right_brc: None,
},
_ => BasicTableWidgetState {
currently_displayed_widget_type: Proc,
currently_displayed_widget_id: DEFAULT_WIDGET_ID,
widget_id: 100,
+ left_tlc: None,
+ left_brc: None,
+ right_tlc: None,
+ right_brc: None,
},
})
} else {
@@ -221,6 +230,7 @@ pub fn build_app(
} else {
1
},
+ disable_click: get_disable_click(matches, config),
};
let used_widgets = UsedWidgets {
@@ -259,6 +269,7 @@ 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 {
let ref_row: Vec<Row>; // Required to handle reference
@@ -297,7 +308,7 @@ pub fn get_widget_layout(
total_row_height_ratio: total_height_ratio,
};
- // Confirm that we have at least ONE widget - if not, error out!
+ // Confirm that we have at least ONE widget left - if not, error out!
if iter_id > 0 {
ret_bottom_layout.get_movement_mappings();
// debug!("Bottom layout: {:#?}", ret_bottom_layout);
@@ -489,9 +500,7 @@ pub fn get_app_grouping(matches: &clap::ArgMatches<'static>, config: &Config) ->
return true;
} else if let Some(flags) = &config.flags {
if let Some(grouping) = flags.group_processes {
- if grouping {
- return true;
- }
+ return grouping;
}
}
false
@@ -502,9 +511,7 @@ pub fn get_app_case_sensitive(matches: &clap::ArgMatches<'static>, config: &Conf
return true;
} else if let Some(flags) = &config.flags {
if let Some(case_sensitive) = flags.case_sensitive {
- if case_sensitive {
- return true;
- }
+ return case_sensitive;
}
}
false
@@ -515,9 +522,7 @@ pub fn get_app_match_whole_word(matches: &clap::ArgMatches<'static>, config: &Co
return true;
} else if let Some(flags) = &config.flags {
if let Some(whole_word) = flags.whole_word {
- if whole_word {
- return true;
- }
+ return whole_word;
}
}
false
@@ -528,9 +533,7 @@ pub fn get_app_use_regex(matches: &clap::ArgMatches<'static>, config: &Config) -
return true;
} else if let Some(flags) = &config.flags {
if let Some(regex) = flags.regex {
- if regex {
- return true;
- }
+ return regex;
}
}
false
@@ -541,9 +544,7 @@ fn get_hide_time(matches: &clap::ArgMatches<'static>, config: &Config) -> bool {
return true;
} else if let Some(flags) = &config.flags {
if let Some(hide_time) = flags.hide_time {
- if hide_time {
- return true;
- }
+ return hide_time;
}
}
false
@@ -554,9 +555,7 @@ fn get_autohide_time(matches: &clap::ArgMatches<'static>, config: &Config) -> bo
return true;
} else if let Some(flags) = &config.flags {
if let Some(autohide_time) = flags.autohide_time {
- if autohide_time {
- return true;
- }
+ return autohide_time;
}
}
@@ -613,14 +612,23 @@ fn get_default_widget_and_count(
}
}
+fn get_disable_click(matches: &clap::ArgMatches<'static>, config: &Config) -> bool {
+ if matches.is_present("DISABLE_CLICK") {
+ return true;
+ } else if let Some(flags) = &config.flags {
+ if let Some(disable_click) = flags.disable_click {
+ return disable_click;
+ }
+ }
+ false
+}
+
pub fn get_use_old_network_legend(matches: &clap::ArgMatches<'static>, config: &Config) -> bool {
if matches.is_present("USE_OLD_NETWORK_LEGEND") {
return true;
} else if let Some(flags) = &config.flags {
if let Some(use_old_network_legend) = flags.use_old_network_legend {
- if use_old_network_legend {
- return true;
- }
+ return use_old_network_legend;
}
}
false
@@ -631,9 +639,7 @@ pub fn get_hide_table_gap(matches: &clap::ArgMatches<'static>, config: &Config)
return true;
} else if let Some(flags) = &config.flags {
if let Some(hide_table_gap) = flags.hide_table_gap {
- if hide_table_gap {
- return true;
- }
+ return hide_table_gap;
}
}
false
@@ -644,9 +650,7 @@ pub fn get_use_battery(matches: &clap::ArgMatches<'static>, config: &Config) ->
return true;
} else if let Some(flags) = &config.flags {
if let Some(battery) = flags.battery {
- if battery {
- return true;
- }
+ return battery;
}
}
false