Clippy & rustfmt

timeout_old
Tassilo Horn 2 years ago
parent cae756bab8
commit 784df6582e
  1. 9
      README.md
  2. 31
      src/tree.rs

@ -324,10 +324,11 @@ right now.
* `fallback_icon` is a path to some PNG/SVG icon which will be used as * `fallback_icon` is a path to some PNG/SVG icon which will be used as
`{app_icon}` if no application-specific icon can be determined. `{app_icon}` if no application-specific icon can be determined.
The placeholders `{app_name}`, `{name}`, `{output_name}`, and `{workspace_name}` The placeholders `{app_name}`, `{name}`, `{output_name}`, and
allow to specify the maximum string length using format `{<name>:<len>}` (e.g. `{workspace_name}` allow to specify the maximum string length using format
`{app_name:10}`). If the string is longer than the specified length, it will `{<name>:<len>}` (e.g. `{app_name:10}`). If the string is longer than the
be truncated and an ellipsis ("…") will be inserted at the end. specified length, it will be truncated and an ellipsis ("…") will be inserted
at the end.
It is crucial that during selection (using wofi or some other menu program) It is crucial that during selection (using wofi or some other menu program)
each window has a different display string. Therefore, it is highly each window has a different display string. Therefore, it is highly

@ -518,33 +518,38 @@ impl DisplayFormat for DisplayNode<'_> {
.unwrap_or_else(String::new) .unwrap_or_else(String::new)
.as_str(), .as_str(),
); );
PLACEHOLDER_RX.replace_all(&fmt, |caps: &regex::Captures| {
PLACEHOLDER_RX
.replace_all(&fmt, |caps: &regex::Captures| {
let value = match &caps["name"] { let value = match &caps["name"] {
"app_name" => self.node.get_app_name(), "app_name" => self.node.get_app_name(),
"name" | "title" => self.node.get_name(), "name" | "title" => self.node.get_name(),
"output_name" => { "output_name" => self
self.tree .tree
.get_parent_node_of_type(self.node.id, Type::Output) .get_parent_node_of_type(self.node.id, Type::Output)
.map_or("<no_output>", |w| w.get_name()) .map_or("<no_output>", |w| w.get_name()),
}, "workspace_name" => self
"workspace_name" => { .tree
self.tree
.get_parent_node_of_type(self.node.id, Type::Workspace) .get_parent_node_of_type(self.node.id, Type::Workspace)
.map_or("<no_workspace>", |w| w.get_name()) .map_or("<no_workspace>", |w| w.get_name()),
},
_ => &caps[0], _ => &caps[0],
}; };
let width = caps.name("width") let width = caps
.name("width")
.map_or("0", |m| m.as_str()) .map_or("0", |m| m.as_str())
.parse::<usize>() .parse::<usize>()
.unwrap(); .unwrap();
if width > 0 && value.len() > width { if width > 0 && value.len() > width {
maybe_html_escape(html_escape, &format!("{}…", &value[..width - 1])) maybe_html_escape(
html_escape,
&format!("{}…", &value[..width - 1]),
)
} else { } else {
maybe_html_escape(html_escape, &value) maybe_html_escape(html_escape, value)
} }
}).into() })
.into()
} }
fn get_indent_level(&self) -> usize { fn get_indent_level(&self) -> usize {

Loading…
Cancel
Save