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

View file

@ -36,7 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- In addition, changed to using only legends within the graph for network, as well as redesigned the legend.
The old legend style can still be used via the `--use_old_network_legend` flag or `use_old_network_legend = true` option.
- Removed header gap on tables.
- Allow for option to hide the header gap on tables.
### Bug Fixes

View file

@ -140,6 +140,8 @@ Run using `btm`.
-R, --regex Search defaults to using regex
-s, --show_disabled_data Shows disabled CPU entries in the CPU legend
-b, --basic Enables basic mode, removing charts and condensing data
--use_old_network_legend Use the older (pre-0.4) network legend which is separate from the network chart
--hide_table_gap Hides the spacing between table headers and data
```
### Options
@ -287,6 +289,8 @@ These are the following supported flag config values:
| `regex` | Boolean |
| `show_disabled_data` | Boolean |
| `basic` | Boolean |
| `hide_table_count`| Boolean |
| `use_old_network_legend`| Boolean |
| `rate` | Unsigned Int (represents milliseconds) |
| `default_time_value` | Unsigned Int (represents milliseconds) |
| `time_delta` | Unsigned Int (represents milliseconds) |

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).

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,
);
}

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],
);
}

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],
);
}

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],
);
}

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()

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
}