Skip to content

Commit

Permalink
add :unindent property (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
nativerv authored Feb 17, 2024
1 parent 4a0901b commit 607f441
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions crates/eww/src/widgets/widget_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 607f441

Please sign in to comment.