From 3a812958598dfa440b6a16d84bd18067ea9ce781 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sun, 30 Jan 2022 15:18:33 +0100 Subject: [PATCH] Revert back accidentally removed {layout} placeholder ...and also rewrite the first sentence in the related paragraph in README and NEWS - there are more placeholders that support formatting than those that do not. It would have been clear from the diff if these files weren't wrapped... I accidentally removed it in commit cae756bab8f183650aac8927d287fe38fd00fc00. --- NEWS.md | 8 ++++---- README.md | 22 +++++++++++----------- src/tree.rs | 1 + 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0efe52f..c19ba04 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,10 @@ swayr v0.13.0 ============= -- The placeholders `{id}`, `{app_name}`, `{name}`/`{title}`, `{output_name}`, - `{workspace_name}`, and `{marks}` may optionally provide a format string as - specified by [Rust's std::fmt](https://doc.rust-lang.org/std/fmt/). The - syntax is `{:}`. For example, +- All the placeholders except `{app_icon}`, `{indent}`, `{urgency_start}`, and + `{urgency_end}` may optionally provide a format string as specified by + [Rust's std::fmt](https://doc.rust-lang.org/std/fmt/). The syntax is + `{:}`. For example, `{app_name:{:>10.10}}` would mean that the application name is printed with exactly 10 characters. If it's shorter, it will be right-aligned (the `>`) and padded with spaces, if it's longer, it'll be cut after the 10th diff --git a/README.md b/README.md index 522a664..f04d18d 100644 --- a/README.md +++ b/README.md @@ -324,17 +324,17 @@ 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 `{id}`, `{app_name}`, `{name}`/`{title}`, `{output_name}`, -`{workspace_name}`, and `{marks}` may optionally provide a format string as -specified by [Rust's std::fmt](https://doc.rust-lang.org/std/fmt/). The syntax -is `{:}`. For example, -`{app_name:{:>10.10}}` would mean that the application name is printed with -exactly 10 characters. If it's shorter, it will be right-aligned (the `>`) and -padded with spaces, if it's longer, it'll be cut after the 10th character. -Another example, `{app_name:{:.10}...}` would mean that the application name is -truncated at 10 characters. If it's shorter, it will be printed as-is (no -padding), if it's longer, it'll be cut after the 10th character and the last -3 characters of that substring will be replaced with `...` (``). +All the placeholders except `{app_icon}`, `{indent}`, `{urgency_start}`, and +`{urgency_end}` may optionally provide a format string as specified by +[Rust's std::fmt](https://doc.rust-lang.org/std/fmt/). The syntax is +`{:}`. For example, `{app_name:{:>10.10}}` +would mean that the application name is printed with exactly 10 characters. If +it's shorter, it will be right-aligned (the `>`) and padded with spaces, if +it's longer, it'll be cut after the 10th character. Another example, +`{app_name:{:.10}...}` would mean that the application name is truncated at 10 +characters. If it's shorter, it will be printed as-is (no padding), if it's +longer, it'll be cut after the 10th character and the last 3 characters of that +substring will be replaced with `...` (``). It is crucial that during selection (using wofi or some other menu program) each window has a different display string. Therefore, it is highly diff --git a/src/tree.rs b/src/tree.rs index eb32493..af0f041 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -516,6 +516,7 @@ impl DisplayFormat for DisplayNode<'_> { let value = match &caps["name"] { "id" => self.node.id.to_string(), "app_name" => self.node.get_app_name().to_string(), + "layout" => format!("{:?}", self.node.layout), "name" | "title" => self.node.get_name().to_string(), "output_name" => self .tree