Allow for aligned text using unindent

This commit is contained in:
elkowar 2021-08-14 16:08:43 +02:00
parent 398717b782
commit f0b27d2ec1
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
3 changed files with 9 additions and 0 deletions

7
Cargo.lock generated
View file

@ -472,6 +472,7 @@ dependencies = [
"tokio-stream",
"tokio-util",
"unescape",
"unindent",
"wait-timeout",
"x11rb",
"yuck",
@ -2254,6 +2255,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "unindent"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7"
[[package]]
name = "utf8-ranges"
version = "1.0.4"

View file

@ -50,6 +50,7 @@ nix = "0.20"
smart-default = "0.6"
simple-signal = "1.1"
unescape = "0.1"
unindent = "0.1"
tokio = { version = "1.0", features = ["full"] }
tokio-stream = "0.1"

View file

@ -543,6 +543,7 @@ fn build_gtk_label(bargs: &mut BuilderArgs) -> Result<gtk::Label> {
prop(text: as_string, limit_width: as_i32 = i32::MAX) {
let text = text.chars().take(limit_width as usize).collect::<String>();
let text = unescape::unescape(&text).context(format!("Failed to unescape label text {}", &text))?;
let text = unindent::unindent(&text);
gtk_widget.set_text(&text);
},
// @prop markup - Pango markup to display