Made table gap optional rather than enforced

This commit is contained in:
ClementTsang
2020-04-19 17:45:32 -04:00
parent b42583e04c
commit f334a72fb1
9 changed files with 28 additions and 6 deletions
+1
View File
@@ -91,6 +91,7 @@ pub struct AppConfigFields {
pub hide_time: bool,
pub autohide_time: bool,
pub use_old_network_legend: bool,
pub table_gap: u16
}
/// AppSearchState deals with generic searching (I might do this in the future).
+1 -1
View File
@@ -346,7 +346,7 @@ impl CpuGraphWidget for Painter {
.map(|calculated_width| Constraint::Length(*calculated_width as u16))
.collect::<Vec<_>>()),
)
.header_gap(0),
.header_gap(app_state.app_config_fields.table_gap),
draw_loc,
);
}
+1 -1
View File
@@ -148,7 +148,7 @@ impl DiskTableWidget for Painter {
.map(|calculated_width| Constraint::Length(*calculated_width as u16))
.collect::<Vec<_>>()),
)
.header_gap(0),
.header_gap(app_state.app_config_fields.table_gap),
margined_draw_loc[0],
);
}
+1 -1
View File
@@ -265,7 +265,7 @@ impl ProcessTableWidget for Painter {
})
.collect::<Vec<_>>()),
)
.header_gap(0),
.header_gap(app_state.app_config_fields.table_gap),
margined_draw_loc[0],
);
}
+1 -1
View File
@@ -149,7 +149,7 @@ impl TempTableWidget for Painter {
.map(|calculated_width| Constraint::Length(*calculated_width as u16))
.collect::<Vec<_>>()),
)
.header_gap(0),
.header_gap(app_state.app_config_fields.table_gap),
margined_draw_loc[0],
);
}
+2 -1
View File
@@ -89,7 +89,8 @@ fn get_matches() -> clap::ArgMatches<'static> {
(@arg AUTOHIDE_TIME: --autohide_time "Automatically hide the time scaling in graphs after being shown for a brief moment when zoomed in/out. If time is disabled via --hide_time then this will have no effect.")
(@arg DEFAULT_WIDGET_TYPE: --default_widget_type +takes_value "The default widget type to select by default.")
(@arg DEFAULT_WIDGET_COUNT: --default_widget_count +takes_value "Which number of the selected widget type to select, from left to right, top to bottom. Defaults to 1.")
(@arg USE_OLD_NETWORK_LEGEND: --use_old_network_legend "Use the old network widget legend.")
(@arg USE_OLD_NETWORK_LEGEND: --use_old_network_legend "Use the older (pre-0.4) network widget legend.")
(@arg HIDE_TABLE_GAP: --hide_table_gap "Hides the spacing between the table headers and entries.")
//(@arg TURNED_OFF_CPUS: -t ... +takes_value "Hides CPU data points by default") // TODO: [FEATURE] Enable disabling cores in config/flags
)
.get_matches()
+16
View File
@@ -41,6 +41,7 @@ pub struct ConfigFlags {
pub default_widget_type: Option<String>,
pub default_widget_count: Option<u64>,
pub use_old_network_legend: Option<bool>,
pub hide_table_gap : Option<bool>,
//disabled_cpu_cores: Option<Vec<u64>>, // TODO: [FEATURE] Enable disabling cores in config/flags
}
@@ -218,6 +219,7 @@ pub fn build_app(
hide_time: get_hide_time(matches, config),
autohide_time,
use_old_network_legend: get_use_old_network_legend(matches, config),
table_gap: if get_hide_table_gap(matches, config){0}else{1},
};
let used_widgets = UsedWidgets {
@@ -618,3 +620,17 @@ pub fn get_use_old_network_legend(matches: &clap::ArgMatches<'static>, config: &
}
false
}
pub fn get_hide_table_gap(matches: &clap::ArgMatches<'static>, config: &Config) -> bool {
if matches.is_present("HIDE_TABLE_GAP") {
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;
}
}
}
false
}