feature: Add option to set a position of legend (#1430)

* Add option to set a position of legend

* some small changes

---------

Co-authored-by: ClementTsang <34804052+ClementTsang@users.noreply.github.com>
This commit is contained in:
Lee WonjoonandClementTsang authored and GitHub committed 2024-04-02 01:06:01 -04:00
1 parent 2ee0df1502
commit a083ec00dd
12 files changed
+169 -41

No files matched your search

+39 -2
View File
@@ -436,6 +436,24 @@ fn mem_args(cmd: Command) -> Command {
to showing it by percentage.",
);
let memory_legend = Arg::new("memory_legend")
.long("memory_legend")
.action(ArgAction::Set)
.value_name("POSITION")
.ignore_case(true)
.help("Where to place the legend for the memory widget.")
.value_parser([
"none",
"top-left",
"top",
"top-right",
"left",
"right",
"bottom-left",
"bottom",
"bottom-right",
]);
#[cfg(not(target_os = "windows"))]
{
let enable_cache_memory = Arg::new("enable_cache_memory")
@@ -443,11 +461,11 @@ fn mem_args(cmd: Command) -> Command {
.action(ArgAction::SetTrue)
.help("Enable collecting and displaying cache and buffer memory.");
cmd.args(args![mem_as_value, enable_cache_memory])
cmd.args(args![mem_as_value, memory_legend, enable_cache_memory])
}
#[cfg(target_os = "windows")]
{
cmd.arg(mem_as_value)
cmd.args(args![mem_as_value, memory_legend])
}
}
@@ -464,6 +482,24 @@ fn network_args(cmd: Command) -> Command {
display is not tested anymore and may be broken.",
);
let network_legend = Arg::new("network_legend")
.long("network_legend")
.action(ArgAction::Set)
.value_name("POSITION")
.ignore_case(true)
.help("Where to place the legend for the network widget.")
.value_parser([
"none",
"top-left",
"top",
"top-right",
"left",
"right",
"bottom-left",
"bottom",
"bottom-right",
]);
let network_use_bytes = Arg::new("network_use_bytes")
.long("network_use_bytes")
.action(ArgAction::SetTrue)
@@ -487,6 +523,7 @@ fn network_args(cmd: Command) -> Command {
cmd.args(args![
use_old_network_legend,
network_legend,
network_use_bytes,
network_use_log,
network_use_binary_prefix,
+2
View File
@@ -68,6 +68,8 @@ pub(crate) struct ConfigFlags {
pub(crate) battery: Option<bool>,
pub(crate) disable_click: Option<bool>,
pub(crate) no_write: Option<bool>,
pub(crate) network_legend: Option<String>,
pub(crate) memory_legend: Option<String>,
/// For built-in colour palettes.
pub(crate) color: Option<String>,
pub(crate) mem_as_value: Option<bool>,