Clippy & rustfmt

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

@ -324,10 +324,11 @@ right now.
* `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.
The placeholders `{app_name}`, `{name}`, `{output_name}`, and `{workspace_name}`
allow to specify the maximum string length using format `{<name>:<len>}` (e.g.
`{app_name:10}`). If the string is longer than the specified length, it will
be truncated and an ellipsis ("…") will be inserted at the end.
The placeholders `{app_name}`, `{name}`, `{output_name}`, and
`{workspace_name}` allow to specify the maximum string length using format
`{<name>:<len>}` (e.g. `{app_name:10}`). If the string is longer than the
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)
each window has a different display string. Therefore, it is highly

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

Loading…
Cancel
Save