add :unindent property (#804)

This commit is contained in:
nativerv 2024-02-17 14:15:05 +03:00 committed by GitHub
parent 4a0901b16c
commit 607f4411d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -27,6 +27,7 @@ All notable changes to eww will be listed here, starting at changes since versio
- Add support for referring to monitor with `<primary>`
- Add support for multiple matchers in `monitor` field
- Add `stack` widget (By: vladaviedov)
- Add `unindent` property to the label widget, allowing to disable removal of leading spaces (By: nrv)
## [0.4.0] (04.09.2022)

View File

@ -2,7 +2,7 @@
use super::{build_widget::BuilderArgs, circular_progressbar::*, run_command, transform::*};
use crate::{
def_widget, enum_parse, error_handling_ctx,
util::{list_difference, unindent},
util::{self, list_difference},
widgets::build_widget::build_gtk_widget,
};
use anyhow::{anyhow, Context, Result};
@ -830,7 +830,8 @@ fn build_gtk_label(bargs: &mut BuilderArgs) -> Result<gtk::Label> {
// @prop limit-width - maximum count of characters to display
// @prop truncate-left - whether to truncate on the left side
// @prop show-truncated - show whether the text was truncated
prop(text: as_string, limit_width: as_i32 = i32::MAX, truncate_left: as_bool = false, show_truncated: as_bool = true) {
// @prop unindent - whether to remove leading spaces
prop(text: as_string, limit_width: as_i32 = i32::MAX, truncate_left: as_bool = false, show_truncated: as_bool = true, unindent: as_bool = true) {
let limit_width = limit_width as usize;
let char_count = text.chars().count();
let text = if char_count > limit_width {
@ -852,7 +853,7 @@ fn build_gtk_label(bargs: &mut BuilderArgs) -> Result<gtk::Label> {
};
let text = unescape::unescape(&text).context(format!("Failed to unescape label text {}", &text))?;
let text = unindent(&text);
let text = if unindent { util::unindent(&text) } else { text };
gtk_widget.set_text(&text);
},
// @prop markup - Pango markup to display